Created
July 4, 2021 18:11
-
-
Save digiwombat/59b3692c225c49817a7aa89ac5bcf186 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using PixelCrushers.DialogueSystem.SuperTextMeshSupport; | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class SequenceSubtitlePanel : SuperTextMeshSubtitlePanel | |
{ | |
public override void Open() | |
{ | |
if (panelState == PanelState.Open || panelState == PanelState.Opening) return; | |
panelState = PanelState.Opening; | |
gameObject.SetActive(true); | |
onOpen.Invoke(); | |
SequenceHandler.Instance.StartCutscene("ShowDialogueBox"); | |
// With quick panel changes, panel may not reach OnEnable/OnDisable before being reused. | |
// Update panelStack here also to handle this case: | |
if (gameObject.activeInHierarchy) StartCoroutine(OpenFinished()); | |
PushToPanelStack(); | |
} | |
private IEnumerator OpenFinished() | |
{ | |
yield return new WaitForSecondsRealtime(0.2f); | |
base.OnVisible(); | |
} | |
private IEnumerator CloseFinished() | |
{ | |
//Debug.Log("Starting to Close Dialogue UI"); | |
yield return new WaitForSecondsRealtime(0.2f); | |
//Debug.Log("Closing all UI"); | |
base.OnHidden(); | |
} | |
public override void Close() | |
{ | |
PopFromPanelStack(); | |
if (gameObject.activeInHierarchy) CancelInvoke(); | |
if (panelState == PanelState.Closed || panelState == PanelState.Closing) return; | |
panelState = PanelState.Closing; | |
onClose.Invoke(); | |
SequenceHandler.Instance.StartCutscene("HideDialogueBox"); | |
if (gameObject.activeInHierarchy) StartCoroutine(CloseFinished()); | |
// Deselect ours: | |
if (UnityEngine.EventSystems.EventSystem.current != null && selectables.Contains(UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject)) | |
{ | |
UnityEngine.EventSystems.EventSystem.current.SetSelectedGameObject(null); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment