Page 1 of 1
[HELP] Clear HUD
Posted: Sun Jan 03, 2021 9:07 am
by mschoenhals
Hi,
I would like to clear the HUD when the player quits to main menu. Right now, main menu will show current HUD status if the player goes back into the main menu after getting a quest. Is there a simple way to clear the HUD?
Thank you in advance.
Re: [HELP] Clear HUD
Posted: Sun Jan 03, 2021 10:01 am
by Tony Li
Hi,
Call the quest HUD's Hide() method to hide it, and Show() to show it again.
For example, in the main menu you could add a script like this:
Code: Select all
using UnityEngine;
using PixelCrushers.QuestMachine;
public class HideHUDInMainMenu : MonoBehaviour
{
void OnStart() // Hide HUD when main menu starts.
{
QuestMachine.defaultQuestHUD.Hide();
}
void OnDestroy() // When leaving this scene (e.g., to gameplay scene), show HUD.
{
QuestMachine.defaultQuestHUD.Show();
}
}
Re: [HELP] Clear HUD
Posted: Mon Jan 04, 2021 7:51 am
by mschoenhals
Thanks for your response Tony. It looks like Show requires some parameters:
Code: Select all
void Show(QuestListContainer questListContainer);
I also see there is a Toggle, but it requires parameters as well. What are the parameters then to include for Show or Toggle?
Re: [HELP] Clear HUD
Posted: Mon Jan 04, 2021 8:39 am
by Tony Li
Hi,
There's also a version of Show() that doesn't require a parameter.
However, it might be clearer in the long run to split it into two scripts. Two separate scripts make it clearer to know what's going on.
In the main menu scene, add this script:
HideHUD.cs
Code: Select all
using UnityEngine;
using PixelCrushers.QuestMachine;
public class HideHUD : MonoBehaviour
{
void Start() // Hide HUD when (main menu) scene starts.
{
QuestMachine.defaultQuestHUD.Hide();
}
}
On your player (in the gameplay scenes), add this script:
ShowHUD.cs
Code: Select all
using UnityEngine;
using PixelCrushers.QuestMachine;
[RequireComponent(typeof(QuestJournal))]
public class ShowHUD : MonoBehaviour
{
void Start() // Show HUD when (gameplay) scene starts.
{
QuestMachine.defaultQuestHUD.Show(GetComponent<QuestJournal>());
}
}
Re: [HELP] Clear HUD
Posted: Sat Jan 09, 2021 9:40 am
by mschoenhals
Hi Tony,
That worked really well, thank you. Would it be possible to do something similar for the Dialogue System? If a player dies or ends game during a dialogue, the dialogue window stays on screen. Is it possible to handle it in the same scripts?
Thank you in advance.
Re: [HELP] Clear HUD
Posted: Sat Jan 09, 2021 11:05 am
by Tony Li
Yes, in the same HideHUD script call:
Code: Select all
PixelCrushers.DialogueSystem.DialogueManager.StopConversation();