Page 1 of 1

Hanging Alert Panel

Posted: Tue May 01, 2018 7:19 pm
by nathanj
Hi Tony

This is a result of my own doing but I'm wondering if you've experienced any hanging with the Alert Panel, as in the message isn't hidden until another alert message is displayed? I have a few different scenarios where this is happening but I believe they're all similar so hopefully the provided example is enough to tell me where I'm in error.

The example I have is with the Timeline Sequencer and the Alert channel plugin with a simple script that skips to the last second of the timeline. If the player presses the skip button (if ((Input.GetButtonDown("Fire2")) || (Input.GetKey(KeyCode.B)))) I have a command to set the Alert Panel to Hide but for some reason this doesn't always work (sometimes it does and sometimes it doesn't, or it appears that way at least) and if so, the message hangs on the screen until another message is displayed.

Any ideas why this might be?

Thanks in advance
Nathan

Code: Select all

using UnityEngine;
using UnityEngine.Playables;
using PixelCrushers.DialogueSystem.TextMeshPro;

public class VSStopTimeline : MonoBehaviour
{
    [SerializeField]
    private PlayableDirector timeline;
    [SerializeField]
    private TextMeshProDialogueUI alertUI;

    
    // Use this for initialization
    public void Update()
    {
        if (timeline != null)
        {
            if (alertUI != null)
            {
                if (timeline.state == PlayState.Playing)
                {
                    if ((Input.GetButtonDown("Fire2")) || (Input.GetKey(KeyCode.B)))
                    {
                        timeline.time = (timeline.duration - 1);
                        alertUI.HideAlert();
                    }
                }
            }
            else
            {
                alertUI = FindObjectOfType<TextMeshProDialogueUI>();
            }      
        }
    }
}

Re: Hanging Alert Panel

Posted: Tue May 01, 2018 8:13 pm
by Tony Li
Hi Nathan,

Try the modification below. It's possible that alertUI is null when you don't expect it to be.

Code: Select all

using UnityEngine;
using UnityEngine.Playables;
using PixelCrushers.DialogueSystem.TextMeshPro;

public class VSStopTimeline : MonoBehaviour
{
    [SerializeField]
    private PlayableDirector timeline;
    [SerializeField]
    private TextMeshProDialogueUI alertUI;

    // Use this for initialization
    public void Update()
    {
        if (alertUI == null) alertUI = FindObjectOfType<TextMeshProDialogueUI>();
        if (timeline != null)
        {
            if (timeline.state == PlayState.Playing)
            {
                if ((Input.GetButtonDown("Fire2")) || (Input.GetKey(KeyCode.B)))
                {
                    timeline.time = (timeline.duration - 1);
                    if (alertUI != null)  alertUI.HideAlert();
                }
            }
        }
    }
}

Re: Hanging Alert Panel

Posted: Tue May 01, 2018 10:22 pm
by nathanj
Thanks tony

That seemed to be it. Thanks for the c# lesson ;)

Pretty sure this is gonna solve a lot of problems for me.

Nathan

Re: Hanging Alert Panel

Posted: Tue May 01, 2018 10:41 pm
by Tony Li
Glad I could help!