Files
beyond/Assets/Scripts/Quests/QuestMachineAlertHelper.cs

40 lines
1.7 KiB
C#

using UnityEngine;
using PixelCrushers.QuestMachine;
using Sirenix.OdinInspector;
using UnityEngine.Rendering; // This 'using' directive is fine
// using PixelCrushers.DialogueSystem; // Only if you need Dialogue System specific things here
public class QuestMachineAlertHelper : MonoBehaviour
{
private string m_message ="";
[Button]
public void ShowQuestMachineAlert(string message)
{
m_message = message;
Invoke("ShowAlertInternal", 0.1f); // Delay to ensure the alert UI is ready for display
}
private void ShowAlertInternal()
{
// Access the static property defaultQuestAlertUI from the static QuestMachine class
if (PixelCrushers.QuestMachine.QuestMachine.defaultQuestAlertUI != null)
{
// Call the ShowAlert method on the assigned UI implementation
PixelCrushers.QuestMachine.QuestMachine.defaultQuestAlertUI.ShowAlert(m_message);
Debug.Log($"Quest Machine Alert triggered via helper: {m_message}");
}
else
{
Debug.LogError("QuestMachineAlertHelper: PixelCrushers.QuestMachine.QuestMachine.defaultQuestAlertUI is null. " +
"Ensure you have a 'QuestMachineConfiguration' component in your scene, " +
"and that its 'Default Alert UI' field is assigned to an active GameObject " +
"that has a component implementing IQuestAlertUI (e.g., a StandardUIQuestAlertDisplayer or similar).");
}
}
// Optional: A method that takes no parameters if you want a fixed alert
public void ShowFixedQuestMachineAlert()
{
ShowQuestMachineAlert("Your fixed alert message here!");
}
}