Hello!
I was trying to customise the Quest HUD to something like this so that each quest has its own group in the Quest HUD:
However, when the game starts, the panel and the icon are still on screen (see below screenshot). I would like them to disappear with the other info and only show up when there's a quest available. Is there a way to do that?
This is my current project hierarchy for the panel and icon.
The panel component is on the ActiveQuest_Template whereas the icon is on the QuestIcon_MainOrSide.
Thanks!
How to make panel and image disappear alongside the quest HUD
Re: How to make panel and image disappear alongside the quest HUD
Hi,
You'll need to make a subclass of UnityUIQuestHUD that overrides the AddQuestsToContent() method. In your version of the method, loop through the quests (see the original method) and instantiate your ActiveQuest_Template to put the quest's contents in. Or, if you prefer, in your overridden method replace the code with your own approach rather than using the templates (activeQuestHeadingTemplate, activeQuestBodyTemplate, etc.). Sometimes for UIs that work differently from the default behavior it's easier to just drop in your own code instead. If you'd like to see an example of either approach, let me know.
You'll need to make a subclass of UnityUIQuestHUD that overrides the AddQuestsToContent() method. In your version of the method, loop through the quests (see the original method) and instantiate your ActiveQuest_Template to put the quest's contents in. Or, if you prefer, in your overridden method replace the code with your own approach rather than using the templates (activeQuestHeadingTemplate, activeQuestBodyTemplate, etc.). Sometimes for UIs that work differently from the default behavior it's easier to just drop in your own code instead. If you'd like to see an example of either approach, let me know.
Re: How to make panel and image disappear alongside the quest HUD
Hi Tony,Tony Li wrote: ↑Thu Apr 10, 2025 11:36 am Hi,
You'll need to make a subclass of UnityUIQuestHUD that overrides the AddQuestsToContent() method. In your version of the method, loop through the quests (see the original method) and instantiate your ActiveQuest_Template to put the quest's contents in. Or, if you prefer, in your overridden method replace the code with your own approach rather than using the templates (activeQuestHeadingTemplate, activeQuestBodyTemplate, etc.). Sometimes for UIs that work differently from the default behavior it's easier to just drop in your own code instead. If you'd like to see an example of either approach, let me know.
Thanks for the reply! I'm not a programmer but it seems like the first method will be the easiest one for me to implement. Would you be able to share an example with me?
Thanks again!
Re: How to make panel and image disappear alongside the quest HUD
Hi,
Here's the example scene:
QM_QuestHUDContainers_2025-04-13.unitypackage
I noticed you're using a pixel art font, so in this example I switched to TextMesh Pro (TMPro) since it does a good job with pixel fonts (Setup guide here).
If you haven't already enabled Quest Machine's TMPro integration, tick the Welcome Window's TMP_PRESENT checkbox or use menu item Tools > Pixel Crushers > Common > Misc > Enable TextMesh Pro Support.
Here's the script that it uses. (This script is included in the package above.)
Here's the example scene:
QM_QuestHUDContainers_2025-04-13.unitypackage
I noticed you're using a pixel art font, so in this example I switched to TextMesh Pro (TMPro) since it does a good job with pixel fonts (Setup guide here).
If you haven't already enabled Quest Machine's TMPro integration, tick the Welcome Window's TMP_PRESENT checkbox or use menu item Tools > Pixel Crushers > Common > Misc > Enable TextMesh Pro Support.
Here's the script that it uses. (This script is included in the package above.)
Code: Select all
using UnityEngine;
using PixelCrushers.QuestMachine;
/// <summary>
/// This subclass of UnityUIQuestHUD adds containers to each quest.
/// </summary>
public class CustomQuestHUD : UnityUIQuestHUD
{
/// <summary>
/// This is the template for the container that will contain each quest.
/// </summary>
[Header("Additional UI Templates")]
[SerializeField]
private UnityUIContentTemplate m_questContainerTemplate;
/// <summary>
/// We'll record the main HUD container so we can add quest containers to it.
/// </summary>
private RectTransform mainContainer = null;
protected override void Awake()
{
base.Awake();
// Make sure we've assigned the quest container template, and deactivate it:
if (m_questContainerTemplate == null && Debug.isDebugBuild) Debug.LogError("Quest Machine: Quest Container Template is unassigned.", this);
if (m_questContainerTemplate != null) m_questContainerTemplate.gameObject.SetActive(false);
}
protected override void RefreshNow()
{
// Before refreshing the HUD, record a reference to the main
// container if we haven't recorded it yet:
if (mainContainer == null) mainContainer = contentContainer;
base.RefreshNow();
}
protected override void AddHeadingContent(HeadingTextQuestContent headingContent)
{
// When we're asked to add a quest heading to a quest, create
// a quest container first. Set this container as the current
// container to hold upcoming quest content:
var containerInstance = Instantiate(m_questContainerTemplate, mainContainer);
currentContentManager.Add(containerInstance, mainContainer);
containerInstance.gameObject.SetActive(true);
contentContainer = containerInstance.transform as RectTransform;
// Then call the base method to add the quest heading to it:
base.AddHeadingContent(headingContent);
}
}
Re: How to make panel and image disappear alongside the quest HUD
Hey, does enabling TextMesh Pro impact performance with lots of pixel art fonts ? i have some perf bugs
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Last edited by Choupad on Wed Apr 30, 2025 11:40 am, edited 1 time in total.
Re: How to make panel and image disappear alongside the quest HUD
No. In some ways, TextMesh Pro will improve performance. Where does the Profiler indicate the performance issue is?
Re: How to make panel and image disappear alongside the quest HUD
Hi Tony,
Thanks for your help and the example, it works perfectly now.
And, sorry for the late reply!!! I was busy with other work stuff. Thanks again!!!
Thanks for your help and the example, it works perfectly now.
And, sorry for the late reply!!! I was busy with other work stuff. Thanks again!!!
Re: How to make panel and image disappear alongside the quest HUD
No problem. Glad to help!