/////////////////////////////////////////////////////// // // Private Methods // /////////////////////////////////////////////////////// /////////////////////////////////////////////////////// // // Contracts // /////////////////////////////////////////////////////// /// <summary> /// Used for AbstractManager memory filling /// </summary> /// <param name="fillSize"></param> protected override void FillReserve(int fillSize) { for (int i = fillSize; i > 0; i--) { SceneHolder newNode = new SceneHolder(); this.reservedList.PushFront(newNode); } }
/// <summary> /// Finds a Scene in the manager and returns it /// </summary> /// <param name="name"></param> /// <returns></returns> public Scene FindScene(Scene.Name name) { Debug.Assert(name != Scene.Name.UNINITIALIZED, "Trying to find an unitialized Scene!"); SceneHolder holder = this.BaseFind(name, this.activeList) as SceneHolder; if (holder == null) { return(null); } return(holder.SceneRef); }
/// <summary> /// This is the prefered method to destroy all the scenes. /// Do NOT use SceneManager.Destroy()! /// </summary> public void UnloadEverything() { // Loop though every scene in the active list SceneHolder itr = this.activeList.Head as SceneHolder; while (itr != null) { // Make this scene the active scene this.activeScene = itr.SceneRef; // Destroy it bool success = this.UnloadScene(this.ActiveSceneName); Debug.Assert(success, "The Scene was not successfully unloaded in UnloadEverything()"); // Next scene itr = this.activeList.Head as SceneHolder; } // Now destroy the nodes holding the scenes this.Destroy(); }
/// <summary> /// Removes a Scene from the manager, given the scene's name /// </summary> /// <param name="oldName"></param> /// <returns></returns> public bool UnloadScene(Scene.Name oldName) { SceneHolder oldHolder = this.BaseRecycle(oldName) as SceneHolder; if (oldHolder == null) { return(false); } // Make the active scene null if it's being removed //if(this.activeScene == oldHolder.SceneRef) //{ // this.activeScene = null; //} // Reset the holder, which unloads the Scene internally oldHolder.Reset(); AudioSourceManager.Self.StopAllAudio(); // Good time to call Garbage collector MemoryJunkyard.Self.RecycleYard(); return(true); }
/////////////////////////////////////////////////////// // // Manager Methods // /////////////////////////////////////////////////////// /// <summary> /// Attaches an already created Scene to the manager /// </summary> /// <param name="newScene"></param> public void AttachScene(Scene newScene) { SceneHolder newHolder = this.BaseCreate() as SceneHolder; newHolder.SetScene(newScene); }