Page 1 of 1

How to make panel and image disappear alongside the quest HUD

Posted: Thu Apr 10, 2025 2:40 am
by yeedesign
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:
Screenshot 2025-04-10 at 4.34.43 PM.png
Screenshot 2025-04-10 at 4.34.43 PM.png (25.86 KiB) Viewed 18113 times
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?
Screenshot 2025-04-10 at 4.35.38 PM.png
Screenshot 2025-04-10 at 4.35.38 PM.png (7.44 KiB) Viewed 18113 times
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.
Screenshot 2025-04-10 at 4.36.32 PM.png
Screenshot 2025-04-10 at 4.36.32 PM.png (40.24 KiB) Viewed 18113 times
Thanks!

Re: How to make panel and image disappear alongside the quest HUD

Posted: Thu Apr 10, 2025 11:36 am
by Tony Li
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.

Re: How to make panel and image disappear alongside the quest HUD

Posted: Sat Apr 12, 2025 7:54 pm
by yeedesign
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.
Hi Tony,

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

Posted: Sun Apr 13, 2025 10:32 am
by Tony Li
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.)

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

Posted: Sun Apr 20, 2025 5:13 am
by Choupad
Hey, does enabling TextMesh Pro impact performance with lots of pixel art fonts ? i have some perf bugs
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Re: How to make panel and image disappear alongside the quest HUD

Posted: Sun Apr 20, 2025 9:01 am
by Tony Li
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

Posted: Fri May 09, 2025 12:09 am
by yeedesign
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!!!

Re: How to make panel and image disappear alongside the quest HUD

Posted: Fri May 09, 2025 7:52 am
by Tony Li
No problem. Glad to help!