Displaying quest log

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Dragonception
Posts: 30
Joined: Sat Jan 19, 2019 2:14 pm

Displaying quest log

Post 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.
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Displaying quest log

Post 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);
    }
}
Dragonception
Posts: 30
Joined: Sat Jan 19, 2019 2:14 pm

Re: Displaying quest log

Post by Dragonception »

That works! Fantastic.
Post Reply