Page 1 of 1

Displaying quest log

Posted: Sun Jan 27, 2019 6:20 am
by Dragonception
I'd like to display the quest log when a quest description in the quest HUD is clicked. Basically the same as what happens when you press the Quest Log hotkey. I've attached the Open() method of the quest log to a button I placed on the HUD' quest description, but this gives: Setting the parent of a transform which resides in a prefab is disabled to prevent data corruption.

Re: Displaying quest log

Posted: Sun Jan 27, 2019 9:10 am
by Tony Li
Hi,

Here's an example: DS_ClickQuestHUDExample_2019-01-27.unitypackage

I put the quest tracker HUD and quest log window in the scene as children of the Dialogue Manager's Canvas, and I removed the prefabs from the Dialogue Manager's Instantiate Prefabs component. This is the key. This way you can hook up behavior in the inspector.

The Quest Track Template has a UI Button that uses the script below when clicked. It assumes that you've set the quest tracker's Quest Description Source to Title, since it uses this to know what quest to open the window on.

OpenQuestLogOnHUDEntry.cs

Code: Select all

using PixelCrushers.DialogueSystem;
using UnityEngine;

public class OpenQuestLogOnHUDEntry : MonoBehaviour
{
    public void OnClickEntry()
    {
        var questLogWindow = FindObjectOfType<QuestLogWindow>();
        questLogWindow.Open();
        questLogWindow.ClickQuest(GetComponent<StandardUIQuestTrackTemplate>().description.text);
    }
}

Re: Displaying quest log

Posted: Sun Jan 27, 2019 9:33 am
by Dragonception
That works! Fantastic.