using System; using System.Collections; using System.Collections.Generic; using PixelCrushers; using PixelCrushers.QuestMachine; using UnityEngine; namespace Beyond { [RequireComponent(typeof(BoxCollider))] public class bAlertTrigger : MonoBehaviour { [SerializeField] private string m_alertHeaderText; [SerializeField] private string m_alertBodyText; [SerializeField] private bool m_showOnce = true; private Collider m_collider; private void OnEnable() { m_collider = GetComponent(); } private void OnTriggerExit(Collider other) { ManageAlert(); if (m_showOnce) { m_collider.enabled = false; } } private void ManageAlert() { List content = new List(); HeadingTextQuestContent headerContent = ScriptableObject.CreateInstance() as HeadingTextQuestContent; StringField header = new StringField(m_alertHeaderText); BodyTextQuestContent bodyContent = ScriptableObject.CreateInstance() as BodyTextQuestContent; StringField body = new StringField(m_alertBodyText); headerContent.headingText = header; bodyContent.bodyText = body; content.Add(headerContent); content.Add(bodyContent); QuestMachine.defaultQuestAlertUI.ShowAlert("", content); StartCoroutine(DelayedDestroyingSO(content)); } private IEnumerator DelayedDestroyingSO(List content) { UnityUIQuestAlertUI ui = QuestMachine.defaultQuestAlertUI as UnityUIQuestAlertUI; if (ui == null) { yield break; } yield return new WaitForSeconds(ui.minDisplayDuration); content.ForEach(Destroy); } } }