/// <summary> /// Runs the trigger sequence. After a specified delay, it will invoke /// the abstract 'OnTrigger' method. /// </summary> protected void RunTriggerSequence() { var seq = StratusActions.Sequence(this.gameObject.Actions()); StratusActions.Delay(seq, this.delay); StratusActions.Call(seq, this.OnTrigger); StratusActions.Call(seq, () => onTriggered(this)); }
//--------------------------------------------------------------------------------------------/ // Methods //--------------------------------------------------------------------------------------------/ /// <summary> /// Shows/hides this window /// </summary> /// <param name="show"></param> /// <param name="onFinished"></param> public void Transition(bool show, System.Action onFinished = null) { if (debug) { StratusDebug.Log(show, this); } if (!show) { eventSystem.SetSelectedGameObject(null); } canvas.blocksRaycasts = show; canvas.interactable = show; pollingInput = show; currentSeq?.Cancel(); currentSeq = StratusActions.Sequence(this); // Fade the canvas StratusActions.Property(currentSeq, () => canvas.alpha, show ? 1f : 0f, transitionSpeed, Ease.Linear); StratusActions.Call(currentSeq, () => { visible = false; }); // Optionally, select the default button if (defaultSelected) { //Trace.Script($"Selecting {defaultSelected.name}", this); if (show) { StratusActions.Call(currentSeq, () => eventSystem.SetSelectedGameObject(defaultSelected.gameObject)); } } // Optionally, reset the state of all other selectables if (controlSelectables) { foreach (var selectable in selectables) { if (selectable == defaultSelected) { continue; } selectable.OnDeselect(null); } } // Now invoke any callbacks if (onFinished != null) { StratusActions.Call(currentSeq, () => { onFinished(); }); } }