//------------------------------------------------------------------------/ // Methods //------------------------------------------------------------------------/ /// <summary> /// Dispatches the event onto the given target /// </summary> /// <returns></returns> public bool Dispatch() { if (!hasType) { return(false); } if (eventInstance == null) { eventInstance = StratusEvent.Instantiate(type, eventData); } switch (scope) { case StratusEvent.Scope.GameObject: foreach (var target in targets) { if (target) { target.Dispatch(eventInstance, type.Type); } } break; case StratusEvent.Scope.Scene: StratusScene.Dispatch(eventInstance, type.Type); break; } return(true); }
/// <summary> /// Closes all scenes in the editor /// </summary> public void CloseAll(StratusScene.SceneCallback onClosed = null) { StratusScene.Unload(scenes, onClosed); //foreach (var scene in this.scenes) // scene.Close(); }
/// <summary> /// Opens all scenes in the editor /// </summary> public void OpenAll(StratusScene.SceneCallback onOpened = null) { StratusScene.Load(scenes, onOpened); //foreach (var scene in this.scenes) // scene.Add(); }
protected override void SetPauseMechanism() { StratusScene.Connect <PauseEvent>(this.OnPauseEvent); gameObject.Connect <PauseEvent>(this.OnPauseEvent); StratusScene.Connect <ResumeEvent>(this.OnResumeEvent); gameObject.Connect <ResumeEvent>(this.OnResumeEvent); }
private void RemoveAllNotes() { ObjectNote[] notes = StratusScene.GetComponentsInAllActiveScenes <ObjectNote>(); foreach (var note in notes) { Undo.DestroyObjectImmediate(note); } StratusDebug.Log($"Removed {notes.Length} notes!"); }
//------------------------------------------------------------------------/ // Messages //------------------------------------------------------------------------/ private void Awake() { // Optionally, subscribe to scene-wide events if (scope == StratusEvent.Scope.Scene) { StratusScene.Connect <StateEvent>(this.OnStateEvent); } // Always subscribe to specific requests gameObject.Connect <StateEvent>(this.OnStateEvent); AddCommonRecorders(); }
private void Subscribe() { switch (scope) { case StratusEvent.Scope.GameObject: this.gameObject.Connect(this.OnEvent, this.type); break; case StratusEvent.Scope.Scene: StratusScene.Connect(this.OnEvent, this.type); break; } connected = true; }
protected override void OnInitializeState() { behaviours = StratusScene.GetComponentsInAllActiveScenes <T>(); }
private static void AddCurrentBehaviours() { StratusManagedBehaviour[] behaviours = StratusScene.GetComponentsInAllActiveScenes <StratusManagedBehaviour>(); StratusDebug.Log($"Adding {behaviours.Length} behaviours"); StratusManagedBehaviourSystem.behaviours.AddRange(behaviours); }
/// <summary> /// Closes/unloads the scene in the editor /// </summary> /// <returns>True if the operation succeeded</returns> public void Close() { StratusScene.Unload(this); }
/// <summary> /// Opens/loads the scene in the editor, adding it to the current list of scenes /// </summary> /// <param name="mode"></param> public void Add() { StratusScene.Load(this); }
/// <summary> /// Unloads this scene (asynchronously) /// </summary> public void Unload(StratusScene.SceneCallback onFinished = null) { StratusScene.Unload(this, onFinished); }
/// <summary> /// Loads this scene /// </summary> /// <param name="mode"></param> public void Load(LoadSceneMode mode, StratusScene.SceneCallback onFinished = null) { StratusScene.Load(this, mode, onFinished); }
public void DispatchToScene() => StratusScene.Dispatch(this, GetType());
//------------------------------------------------------------------------/ // Messages //------------------------------------------------------------------------/ protected override void OnAwake() { StratusScene.Connect <StratusPauseEvent>(this.OnPauseEvent); StratusScene.Connect <StratusResumeEvent>(this.OnResumeEvent); }