Page 1 of 1
Hide UI during dialogue
Posted: Tue Nov 03, 2020 7:58 am
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.
Re: Hide UI during dialogue
Posted: Tue Nov 03, 2020 8:14 am
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();
}
}
Re: Hide UI during dialogue
Posted: Tue Nov 03, 2020 1:45 pm
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!
Re: Hide UI during dialogue
Posted: Tue Nov 03, 2020 2:21 pm
by Tony Li
Happy to help!
Re: Hide UI during dialogue
Posted: Wed Nov 25, 2020 11:37 am
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.
Re: Hide UI during dialogue
Posted: Wed Nov 25, 2020 12:15 pm
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: