Hanging Alert Panel

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
nathanj
Posts: 303
Joined: Sat May 28, 2016 12:30 am

Hanging Alert Panel

Post 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>();
            }      
        }
    }
}
User avatar
Tony Li
Posts: 22059
Joined: Thu Jul 18, 2013 1:27 pm

Re: Hanging Alert Panel

Post 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();
                }
            }
        }
    }
}
User avatar
nathanj
Posts: 303
Joined: Sat May 28, 2016 12:30 am

Re: Hanging Alert Panel

Post 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
User avatar
Tony Li
Posts: 22059
Joined: Thu Jul 18, 2013 1:27 pm

Re: Hanging Alert Panel

Post by Tony Li »

Glad I could help!
Post Reply