[HOWTO] Add More Track Toggle Options To Quest Log Window
Posted: Mon Apr 29, 2024 8:33 pm
This script adds the ability to toggle tracking of the selected quest by pressing a key or input button, or by showing a track UI button in the quest details. Replace your Standard UI Quest Log Window component's script in place with this one, add a track button to the quest details section, and assign it to the Track Button Template in the inspector.
CustomQuestLogWindow.cs
CustomQuestLogWindow.cs
Code: Select all
using UnityEngine;
using PixelCrushers;
using PixelCrushers.DialogueSystem;
public class CustomQuestLogWindow : StandardUIQuestLogWindow
{
public StandardUIButtonTemplate trackButtonTemplate;
public KeyCode trackToggleKey = KeyCode.C;
public string trackToggleButton = "";
protected override void Start()
{
base.Start();
Tools.SetGameObjectActive(trackButtonTemplate, false);
}
private void Update()
{
if (isOpen && !string.IsNullOrEmpty(selectedQuest) &&
(InputDeviceManager.IsKeyDown(trackToggleKey) || InputDeviceManager.IsButtonDown(trackToggleButton)))
{
ClickTrackQuest(selectedQuest);
}
}
protected override void RepaintSelectedQuest(QuestInfo quest)
{
base.RepaintSelectedQuest(quest);
if (quest != null)
{
var isTrackable = QuestLog.IsQuestTrackingAvailable(quest.Title);
if (isTrackable)
{
var trackButton = detailsPanelContentManager.Instantiate<StandardUIButtonTemplate>(trackButtonTemplate);
detailsPanelContentManager.Add(trackButton, questDetailsContentContainer);
trackButton.button.onClick.AddListener(() => ClickTrackQuest(selectedQuest));
}
}
}
}