Page 1 of 1

Disabling alert cross scene

Posted: Sat Apr 23, 2016 6:02 am
by mandi
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!

Re: Disabling alert cross scene

Posted: Sat Apr 23, 2016 10:12 am
by Tony Li
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.

Re: Disabling alert cross scene

Posted: Sat Apr 23, 2016 10:39 am
by mandi
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!

Re: Disabling alert cross scene

Posted: Tue Oct 20, 2020 12:54 pm
by ludm
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:

Code: Select all

[SerializeField] protected GameObject subTitleGo;
Get the animator:

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

Posted: Tue Oct 20, 2020 9:44 pm
by ludm
One limitation is that it works only if the panel has been displayed once.
Do you know how I could get over this limitation ?

Re: Disabling alert cross scene

Posted: Tue Oct 20, 2020 11:08 pm
by Tony Li
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:

alternateShowHideAnimator.png
alternateShowHideAnimator.png (21.09 KiB) Viewed 693 times

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

Posted: Wed Oct 21, 2020 8:46 am
by ludm
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

Code: Select all

DialogueManager.displaySettings.subtitleSettings.showNPCSubtitlesDuringLine
Like this:
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);
So it works well with the original animator and these codes

Re: Disabling alert cross scene

Posted: Wed Oct 21, 2020 11:48 am
by Tony Li
Hi,

Can you click on the error message, press Ctrl+C, and paste it in here please?