//------------------------------------------------------------------------/
        // 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);
        }
Beispiel #2
0
        /// <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();
        }
Beispiel #3
0
        /// <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;
        }
Beispiel #8
0
 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);
 }
Beispiel #10
0
 /// <summary>
 /// Closes/unloads the scene in the editor
 /// </summary>
 /// <returns>True if the operation succeeded</returns>
 public void Close()
 {
     StratusScene.Unload(this);
 }
Beispiel #11
0
 /// <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);
 }
Beispiel #12
0
 /// <summary>
 /// Unloads this scene (asynchronously)
 /// </summary>
 public void Unload(StratusScene.SceneCallback onFinished = null)
 {
     StratusScene.Unload(this, onFinished);
 }
Beispiel #13
0
 /// <summary>
 /// Loads this scene
 /// </summary>
 /// <param name="mode"></param>
 public void Load(LoadSceneMode mode, StratusScene.SceneCallback onFinished = null)
 {
     StratusScene.Load(this, mode, onFinished);
 }
Beispiel #14
0
 public void DispatchToScene() => StratusScene.Dispatch(this, GetType());
 //------------------------------------------------------------------------/
 // Messages
 //------------------------------------------------------------------------/
 protected override void OnAwake()
 {
     StratusScene.Connect <StratusPauseEvent>(this.OnPauseEvent);
     StratusScene.Connect <StratusResumeEvent>(this.OnResumeEvent);
 }