Hide UI during dialogue

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Jon
Posts: 5
Joined: Tue Nov 03, 2020 7:56 am

Hide UI during dialogue

Post by Jon »

Is there anything within the Dialogue System that can disable UI elements during dialogues or do I need to script something myself? Parts of my UI (inventory ui) blocks parts of the dialogue box.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Hide UI during dialogue

Post by Tony Li »

Hi,

Add a Dialogue System Events component to the Dialogue Manager. Configure the OnConversationStart() UnityEvent to hide your other UI elements. Configure OnConversationEnd() to show them again.

If you don't have a permanent reference to the UI elements that you can assign to those UnityEvents, you can write a script with OnConversationStart() and OnConversationEnd() methods such as:

Code: Select all

public class HideOtherUIsDuringConversations : MonoBehaviour
{
    void OnConversationStart(Transform actor)
    { // (Example)
        FindObjectOfType<InventoryUI>().Hide();
    }
    void OnConversationEnd(Transform actor)
    { // (Example)
        FindObjectOfType<InventoryUI>().Show();
    }
}
Jon
Posts: 5
Joined: Tue Nov 03, 2020 7:56 am

Re: Hide UI during dialogue

Post by Jon »

Tony Li wrote: Tue Nov 03, 2020 8:14 am Hi,

Add a Dialogue System Events component to the Dialogue Manager. Configure the OnConversationStart() UnityEvent to hide your other UI elements. Configure OnConversationEnd() to show them again.

If you don't have a permanent reference to the UI elements that you can assign to those UnityEvents, you can write a script with OnConversationStart() and OnConversationEnd() methods such as:

Code: Select all

public class HideOtherUIsDuringConversations : MonoBehaviour
{
    void OnConversationStart(Transform actor)
    { // (Example)
        FindObjectOfType<InventoryUI>().Hide();
    }
    void OnConversationEnd(Transform actor)
    { // (Example)
        FindObjectOfType<InventoryUI>().Show();
    }
}


Ahhhhh alright! Thank you!
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Hide UI during dialogue

Post by Tony Li »

Happy to help!
NotVeryProfessional
Posts: 150
Joined: Mon Nov 23, 2020 6:35 am

Re: Hide UI during dialogue

Post by NotVeryProfessional »

Tony Li wrote: Tue Nov 03, 2020 8:14 am If you don't have a permanent reference to the UI elements that you can assign to those UnityEvents, you can write a script with OnConversationStart() and OnConversationEnd() methods such as:
I think there's a step missing there. I've done that and the script does not receive those events and nothing gets executed.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Hide UI during dialogue

Post by Tony Li »

Hi,

The OnConversationStart and OnConversationEnd methods are only called on the Dialogue Manager and the GameObjects associated with the conversation's primary participants. Make sure the script is on one of the participants. If you can't put it on one of the participants, hook into the equivalent C# events.

More info:
Post Reply