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.
[HELP] Clear HUD
Re: [HELP] Clear HUD
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:
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();
}
}
-
- Posts: 118
- Joined: Thu Dec 19, 2019 7:38 am
Re: [HELP] Clear HUD
Thanks for your response Tony. It looks like Show requires some parameters:
I also see there is a Toggle, but it requires parameters as well. What are the parameters then to include for Show or Toggle?
Code: Select all
void Show(QuestListContainer questListContainer);
Re: [HELP] Clear HUD
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
On your player (in the gameplay scenes), add this script:
ShowHUD.cs
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();
}
}
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>());
}
}
-
- Posts: 118
- Joined: Thu Dec 19, 2019 7:38 am
Re: [HELP] Clear HUD
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.
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
Yes, in the same HideHUD script call:
Code: Select all
PixelCrushers.DialogueSystem.DialogueManager.StopConversation();