Disabling alert cross scene
Disabling alert cross scene
Hello Tony,
how to disable alerts completely? I have this strange behaviour - when I load new scene, an alert appears pertaining to the object killed in the previous (I guess).
Best!
how to disable alerts completely? I have this strange behaviour - when I load new scene, an alert appears pertaining to the object killed in the previous (I guess).
Best!
Re: Disabling alert cross scene
Hello Artur,
To disable alerts, make them invisible. If you're using Unity UI, one way is to leave the Alert Panel's Canvas Group > Alpha at 0, remove the Animator component, and on the Unity UI Dialogue UI component set the Show and Hide animation names to blank strings.
However, the reason for the strange behavior is probably a component that fires when its object is destroyed, such as Increment On Destroy. This component is frequently used to keep track of kills in a kill quest. When you "kill" the GameObject and destroy it, this component increments a Dialogue System variable and shows an alert message.
However, when you unload the previous scene, this also destroys all of its objects. The solution in this case is to call PersistentDataManager.LevelWillBeUnloaded() before loading the new scene. This tells components like Increment On Destroy to ignore the next "OnDestroy" message.
If you use the LevelManager.LoadLevel() or the LoadLevel() sequencer command to change levels, it automatically calls PersistentDataManager.LevelWillBeUnloaded() for you.
To disable alerts, make them invisible. If you're using Unity UI, one way is to leave the Alert Panel's Canvas Group > Alpha at 0, remove the Animator component, and on the Unity UI Dialogue UI component set the Show and Hide animation names to blank strings.
However, the reason for the strange behavior is probably a component that fires when its object is destroyed, such as Increment On Destroy. This component is frequently used to keep track of kills in a kill quest. When you "kill" the GameObject and destroy it, this component increments a Dialogue System variable and shows an alert message.
However, when you unload the previous scene, this also destroys all of its objects. The solution in this case is to call PersistentDataManager.LevelWillBeUnloaded() before loading the new scene. This tells components like Increment On Destroy to ignore the next "OnDestroy" message.
If you use the LevelManager.LoadLevel() or the LoadLevel() sequencer command to change levels, it automatically calls PersistentDataManager.LevelWillBeUnloaded() for you.
Re: Disabling alert cross scene
Tony,
yes, I had the UI disabled, and suspected an event fired on destroy was being picked up by the alert system. PersistentDataManager.LevelWillBeUnloaded() is the fix I need, I guess
Thanks!
yes, I had the UI disabled, and suspected an event fired on destroy was being picked up by the alert system. PersistentDataManager.LevelWillBeUnloaded() is the fix I need, I guess
Thanks!
Re: Disabling alert cross scene
I was looking for a solution to toggle the visibility of the subtitle panel with a button. I wanted to keep the animation on the panel. So the trick was to use the Hide and Show animations when (de)activating. Here is a solution to achieve this:
Get the animator:
Show the panel:
Hide the panel:
Code: Select all
[SerializeField] protected GameObject subTitleGo;
Code: Select all
subTtlAnim = subTitleGo.GetComponent<Animator>();
Show the panel:
Code: Select all
subTitleGo.SetActive(true);
subTtlAnim.SetTrigger("Show");
Hide the panel:
Code: Select all
subTtlAnim.SetTrigger("Hide");
subTitleGo.SetActive(false);
Re: Disabling alert cross scene
One limitation is that it works only if the panel has been displayed once.
Do you know how I could get over this limitation ?
Do you know how I could get over this limitation ?
Re: Disabling alert cross scene
Hi,
You can change your animator controller.
The basic Canvas Group Animator Controller has three states: Start (hidden), Show, and Hide.
The Show and Hide trigger parameters link from Any State to the Show and Hide states.
You could change this so nothing links from Any State. Example:
The magenta Show and Hide indicate the trigger parameters that trigger the transitions above. "Default" means is triggers automatically. Please these at the bottom of the transition list so they only take effect if the Show or Hide trigger parameters aren't set.
You can change your animator controller.
The basic Canvas Group Animator Controller has three states: Start (hidden), Show, and Hide.
The Show and Hide trigger parameters link from Any State to the Show and Hide states.
You could change this so nothing links from Any State. Example:
The magenta Show and Hide indicate the trigger parameters that trigger the transitions above. "Default" means is triggers automatically. Please these at the bottom of the transition list so they only take effect if the Show or Hide trigger parameters aren't set.
Re: Disabling alert cross scene
Thanks,
I have change the animator, but I still have a problem:
When I try to hide subTtlAnim.SetTrigger("Hide"); in Start(), it throws a nullReferenceException
subTitleGo.SetActive(false); seems to be ok
But, then I start the conversation, the panel is displayed, even if subTitleGo.SetActive(false) has been set. Maybe one function in Dialogue System setActive to true when beginning the conversation.
Finally like you mentioned in another thread, I used
Like this:
Add
So it works well with the original animator and these codes
I have change the animator, but I still have a problem:
When I try to hide subTtlAnim.SetTrigger("Hide"); in Start(), it throws a nullReferenceException
subTitleGo.SetActive(false); seems to be ok
But, then I start the conversation, the panel is displayed, even if subTitleGo.SetActive(false) has been set. Maybe one function in Dialogue System setActive to true when beginning the conversation.
Finally like you mentioned in another thread, I used
Code: Select all
DialogueManager.displaySettings.subtitleSettings.showNPCSubtitlesDuringLine
Add
Code: Select all
using PixelCrushers.DialogueSystem;
Code: Select all
DialogueManager.displaySettings.subtitleSettings.showNPCSubtitlesDuringLine = true;
subTitleGo.SetActive(true);
subTtlAnim.SetTrigger("Show");
Code: Select all
try
{
subTtlAnim.SetTrigger("Hide");
}
catch (Exception e)
{
Debug.Log("not loaded yet");
}
DialogueManager.displaySettings.subtitleSettings.showNPCSubtitlesDuringLine = false;
subTitleGo.SetActive(false);
Re: Disabling alert cross scene
Hi,
Can you click on the error message, press Ctrl+C, and paste it in here please?
Can you click on the error message, press Ctrl+C, and paste it in here please?