Alert shows on load

Announcements, support questions, and discussion for the Dialogue System.
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: Alert shows on load

Post by Tony Li »

supadupa64 wrote:Before I dive into those other things you suggested, I did notice this one thing. When I'm loading a game the player ports to the very start of the game, then to the spot where he is supposed to be.
That's just the way loading works. The scene starts the way you designed it. In the first frame, the save system applies the changes recorded in the saved game. You can mask this by covering the whole screen with a black texture. Add a Sequence Trigger set to OnStart that deactivates the whole-screen cover and running a Fade(in) sequencer command.
supadupa64 wrote:I was watching the quests that are being tracked in the top of the screen and noticed that if I was on a quest collecting 10 scrolls and I had currently collected 5/10, on a frame in between the loading it says something like 8/10 collected or 9/10 collected. I saw it change a couple times which probably is the cause of this alert being shown on load.

Do you know how this could happen?
Sounds like the current scene's Increment On Destroy components are still triggering.

When you load a game, this happens:
  • Unity invokes OnDisable and OnDestroy on all enabled components on active GameObjects in the current scene.
  • Unity unloads all GameObjects in the current scene.
  • Unity loads all GameObjects in the saved game's scene. (This may be the same scene as the current scene, but Unity still follows this process.)
  • Unity invokes Awake and Start.
The catch is the first bullet. Increment On Destroy triggers in OnDestroy. This means that when you load a game, those Increment On Destroy components in the current scene bump up the scrolls to 8/10 or 9/10.

To address this, the Dialogue System can tell all current components (such as Increment On Destroy) to ignore the next OnDisable/OnDestroy. Internally, to do this you invoke PersistentDataManager.LevelWillBeUnloaded. It sounds like, however you're loading your game, it's not invoking PersistentDataManager.LevelWillBeUnloaded.

If I recall correctly, you're using the Dialogue System Menu Template prefab. If this is the case, make sure your Dialogue Manager GameObject has a Level Manager component. This component takes care of invoking PersistentDataManager.LevelWillBeUnloaded.

However, if you're using a loading scene, you'll want to make this change to SaveHelper.cs:

Change this: (starting line 145)

Code: Select all

if (useLoadingScene)
{
    LoadingScene.SetLoadGameData(saveData);
    SceneManager.LoadScene(loadingSceneIndex);
}
to this:

Code: Select all

if (useLoadingScene)
{
    LoadingScene.SetLoadGameData(saveData);
    PersistentDataManager.LevelWillBeUnloaded(); //<--ADD THIS.
    SceneManager.LoadScene(loadingSceneIndex);
}
Also check your Console window for any warnings or errors.
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Re: Alert shows on load

Post by supadupa64 »

I was looking at the options for Fade() in the doc area. Is it set up where an image can be loaded so I can place "loading..." in the middle of the screen? I noticed a color and delay time can be added. I actually tried to set this up through the UI before and sorta broke it.
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: Alert shows on load

Post by Tony Li »

The Fade() sequencer command only fades to/from a solid color. For example:

Code: Select all

Fade(out,1,#ffffff)
fades to white over 1 second.

If you want a loading image and you don't want to use a separate loading scene, try this:

1. Add the loading image to a canvas under your Dialogue Manager. It can be the normal Dialogue Manager canvas or, if you have other canvases that are on a higher layer than the normal canvas, add it to the highest layer canvas to make sure it always covers everything. Let's say it's named LoadingImage.

2. Add an Animator component to LoadingImage.

3. Create two animations using the Animation window:
  • Show: This can be just one frame. Set the image's Alpha value to 1.
  • Fade: Animate the Alpha value from 1 to 0 over some duration (like 1 second).
After you create these animation clips, inspect them in your project and UNtick the Loop checkbox.

4. In the animator controller, make sure Show is the default animator state.

5. Add a Sequence Trigger set to OnStart. Set the Sequence to:

Code: Select all

AnimatorPlay(Fade,LoadingImage)
6. Create a C# script named ShowLoadingImage containing the code below, and add it to the Dialogue Manager:

Code: Select all

using UnityEngine;

public class ShowLoadingImage : MonoBehaviour {
    public Animator loadingImageAnimator; //<-- ASSIGN THIS IN INSPECTOR!
    
    public void OnLevelWillBeUnloaded() {
        loadingImageAnimator.Play("Show");
    }
} 
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Re: Alert shows on load

Post by supadupa64 »

Here's what I added. I'm missing something... I don't see any change when loading a game.
loading image screen1.jpg
loading image screen1.jpg (112.54 KiB) Viewed 2788 times
loading image screen2.jpg
loading image screen2.jpg (121.94 KiB) Viewed 2788 times
loading image screen3.jpg
loading image screen3.jpg (71.48 KiB) Viewed 2788 times
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: Alert shows on load

Post by Tony Li »

Here's an example:

LoadingImageExample_2016-12-18.unitypackage

Since I used a Canvas, I used an Image instead of a SpriteRenderer.

Also, I put the Sequence Trigger on a GameObject in the scene that isn't part of the Dialogue Manager. You'll want to put this in every gameplay scene.

To test the example scene, play it, press Escape, and save your game. Then press Escape again and load your game. You'll see the "Loading..." image appear before it loads the scene. After loading, the image will fade away.
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Re: Alert shows on load

Post by supadupa64 »

I got this working I think. Seems to do the job. Thanks!

By the way, to visit the "alert shows on load" subject, I still get this alert almost every time I load a game. I usually plays the alert of the quest objects I'm currently collecting. I do have the level manager component attached to the Dialogue Manager.

Also, I fixed one of those camera errors I had with the Opsive controller and was able to load probably two or three times more loads until the controls got messed up, and when they did it wasn't nearly as bad as before. I just have one more error I'm trying to figure out.
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: Alert shows on load

Post by Tony Li »

To recap those TPC issues, they were:

Code: Select all

Warning: The CharacterRagdoll component has been deprecated. Please add the Die ability to the character with a manual start and stop type.
Warning: The ItemColliderPosition component has been deprecated as of version 1.3. Please remove this component and the SphereCollider from your character.
They should just be a matter of updating your character setups.

The log also showed these errors:

Code: Select all

Error: Unable to find camera state with name Zoom
Error: Unable to find camera state with name StaticHeight
Error: Unable to transition to Base Layer.Movement because the state doesn't exist.
I suggested these two things to try:

1. Try setting the Dialogue System Third Person Controller Bridge script's execution order to something like, like 999. See here for instructions: https://docs.unity3d.com/Manual/class-S ... ution.html

2. If you've also added this script to NPCs, make sure the Override Actor Name is only set to "Player" for the player character. If the other characters (NPCs) are tagged "Player", change their tags or set their Overide Actor Name to a non-blank string.

I also sent you an updated Third Person Controller Support package that lets you tell the bridge to delay a certain number of frames before manipulating TPC with the saved game data (such as moving the TPC-controller character to its saved position). You can use this to ensure that TPC is all initialized first.

Can you please remind me -- are you using a loading scene? (Is your Save Helper component's Use Loading Scene checkbox ticked?)
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Re: Alert shows on load

Post by supadupa64 »

A)
I fixed these two:
Error: Unable to find camera state with name Zoom
Error: Unable to find camera state with name StaticHeight

B)
Not sure what's going on with:
Error: Unable to transition to Base Layer.Movement because the state doesn't exist.

C)
Where is the Save Help component supposed to be applied?

D)
I made the Dialogue System Third Person Controller Bridge script's execution 999. It wasn't there, so I manually added it, but it had pixelcrushers... etc before it. I'm only using the Dialogue System Third Person Controller Bridge on the main player.

E)
Not exactly sure what you mean by using a loading scene, but I'm using https://www.assetstore.unity3d.com/en/#!/content/40465.
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: Alert shows on load

Post by Tony Li »

supadupa64 wrote:A)
I fixed these two:
Error: Unable to find camera state with name Zoom
Error: Unable to find camera state with name StaticHeight
Great!
supadupa64 wrote:B)
Not sure what's going on with:
Error: Unable to transition to Base Layer.Movement because the state doesn't exist.
Let's ignore it for now. We might need to come back to it if we can't get things cleaned up otherwise. This means a character's RigidbodyCharacterController component has an animator controller that doesn't have a state named "Movement" on its Base Layer, or at least the RigidbodyCharacterController thinks for some reason that it doesn't have this state.
supadupa64 wrote:C)
Where is the Save Help component supposed to be applied?
It's on the UI GameObject. If Use Loading Scene is ticked, it will load the scene whose build index is Loading Scene Index. If it's unticked, SaveHelper will load the saved game scene immediately.
supadupa64 wrote:D)
I made the Dialogue System Third Person Controller Bridge script's execution 999. It wasn't there, so I manually added it, but it had pixelcrushers... etc before it. I'm only using the Dialogue System Third Person Controller Bridge on the main player.
Good to know. That simplifies things a lot to only have the Bridge on the main player. Did it help?

If it doesn't fix the issue, try importing the updated Third Person Controller Support package that I emailed you. This will add a new field Frames To Wait Before Applying Persistent Data to the Bridge. Set it to 2 and see if that helps.
supadupa64 wrote:E)
Not exactly sure what you mean by using a loading scene, but I'm using https://www.assetstore.unity3d.com/en/#!/content/40465.
Good; that's what I thought. You're using the Unity Game Jam Menu Template and the Dialogue System's Menu Template Prefab that works on top of it to add features like loading and saving games.
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Re: Alert shows on load

Post by supadupa64 »

On my UI gameobject I have a save helper component, but there's no option to box check anything. There's only an option to change Empty Slot Text.

Just to clarify and not get things mixed up, here are the two main problems.
1) Alert shows on load
2) Controls get messed up on load

To be sure, you're saying if I update the TPC you sent it may help with loading a game?
I changed the script order for the bridge component to 999 and it didn't seem to do anything. I'll keep checking on it.

By the way, don't feel like you need to respond tonight. It's New Years Eve!
Post Reply