quest machine alert helper added to show alers when receiveing quest from dialogue
This commit is contained in:
File diff suppressed because it is too large
Load Diff
40
Assets/Scripts/Quests/QuestMachineAlertHelper.cs
Normal file
40
Assets/Scripts/Quests/QuestMachineAlertHelper.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
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!");
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Quests/QuestMachineAlertHelper.cs.meta
Normal file
2
Assets/Scripts/Quests/QuestMachineAlertHelper.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25ed874c9c0994437beb4203d846dbe3
|
||||
Reference in New Issue
Block a user