protected internal override IProgressingYieldInstruction DoLoadAdditiveAsync() { var arr = new IProgressingYieldInstruction[this.ChildCount]; for (int i = 0; i < this.ChildCount; i++) { arr[i] = this.GetChild(i).DoLoadAdditiveAsync(); } return new ProgressingYieldInstructionQueue(arr); }
protected internal override IProgressingYieldInstruction DoLoadAdditiveAsync() { var arr = new IProgressingYieldInstruction[this.ChildCount]; for (int i = 0; i < this.ChildCount; i++) { arr[i] = this.GetChild(i).DoLoadAdditiveAsync(); } return(new ProgressingYieldInstructionQueue(arr)); }
public BeforeSceneLoadedEventArgs(string sceneName, LoadSceneMode mode, IProgressingYieldInstruction async) { this.SceneName = sceneName; this.Mode = mode; this.AsyncHandle = async; }
private System.Collections.IEnumerator DoLoad() { if(_lastScene != null) { //end last scene var endInstruction = _lastScene.EndScene(); if (endInstruction != null) yield return endInstruction; if(_manager._lastSceneBehaviour == _lastScene) _manager._lastSceneBehaviour = null; } var args = new SceneLoadingEventArgs(_manager, _options); object[] instructions; //signal about to load _options.OnBeforeSceneLoaded(_manager, args); _manager.OnBeforeSceneLoaded(args); if (args.ShouldStall(out instructions)) yield return new WaitForAllComplete(GameLoopEntry.Hook, instructions); //do load var scene = _options.GetScene(_manager); _loadOp = (scene != null) ? scene.LoadAsync() : RadicalYieldInstruction.Null; yield return _loadOp; //get scene behaviour var sceneBehaviour = _options.LoadCustomSceneBehaviour(_manager); if(sceneBehaviour == null) { var go = new GameObject("SceneBehaviour"); go.transform.parent = _manager.transform; go.transform.localPosition = Vector3.zero; sceneBehaviour = go.AddComponent<SceneBehaviour>(); } SceneBehaviour.SceneLoadedInstance = sceneBehaviour; _manager._currentSceneBehaviour = sceneBehaviour; //signal loaded _options.OnSceneLoaded(_manager, args); _manager.OnSceneLoaded(args); if (args.ShouldStall(out instructions)) yield return new WaitForAllComplete(GameLoopEntry.Hook, instructions); else yield return null; //wait one last frame to actually begin the scene //signal scene begun _started = true; var beginInstruction = sceneBehaviour.BeginScene(); _options.OnSceneStarted(_manager, args); _manager.OnSceneStarted(args); if (args.ShouldStall(out instructions)) { var waitAll = new WaitForAllComplete(GameLoopEntry.Hook, instructions); if (beginInstruction != null) waitAll.Add(beginInstruction); beginInstruction = waitAll; } if (beginInstruction != null) yield return beginInstruction; _manager._loadingOp = null; this.SetSignal(); }
public void Start(Scene scene, IProgressingYieldInstruction innerOp) { _scene = scene; _op = innerOp; GameLoopEntry.Hook.StartRadicalCoroutine(this.WaitForLoadRoutine(), RadicalCoroutineDisableMode.Default); }
private System.Collections.IEnumerator DoLoad() { if (_lastScene != null) { //end last scene var endInstruction = _lastScene.EndScene(); if (endInstruction != null) { yield return(endInstruction); } if (_manager._lastSceneBehaviour == _lastScene) { _manager._lastSceneBehaviour = null; } } var args = new SceneLoadingEventArgs(_manager, _options); object[] instructions; //signal about to load _options.OnBeforeSceneLoaded(_manager, args); _manager.OnBeforeSceneLoaded(args); if (args.ShouldStall(out instructions)) { yield return(new WaitForAllComplete(GameLoopEntry.Hook, instructions)); } //do load var scene = _options.GetScene(_manager); _loadOp = (scene != null) ? scene.LoadAsync() : RadicalYieldInstruction.Null; yield return(_loadOp); //get scene behaviour var sceneBehaviour = _options.LoadCustomSceneBehaviour(_manager); if (sceneBehaviour == null) { var go = new GameObject("SceneBehaviour"); go.transform.parent = _manager.transform; go.transform.localPosition = Vector3.zero; sceneBehaviour = go.AddComponent <SceneBehaviour>(); } SceneBehaviour.SceneLoadedInstance = sceneBehaviour; _manager._currentSceneBehaviour = sceneBehaviour; //signal loaded _options.OnSceneLoaded(_manager, args); _manager.OnSceneLoaded(args); if (args.ShouldStall(out instructions)) { yield return(new WaitForAllComplete(GameLoopEntry.Hook, instructions)); } else { yield return(null); //wait one last frame to actually begin the scene } //signal scene begun _started = true; var beginInstruction = sceneBehaviour.BeginScene(); _options.OnSceneStarted(_manager, args); _manager.OnSceneStarted(args); if (args.ShouldStall(out instructions)) { var waitAll = new WaitForAllComplete(GameLoopEntry.Hook, instructions); if (beginInstruction != null) { waitAll.Add(beginInstruction); } beginInstruction = waitAll; } if (beginInstruction != null) { yield return(beginInstruction); } _manager._loadingOp = null; this.SetSignal(); }
protected virtual void OnBeforeSceneLoaded(string sceneName, LoadSceneMode mode, IProgressingYieldInstruction async) { var d = this.BeforeSceneLoaded; if (d == null) { return; } var e = _beforeArgs; _beforeArgs = null; if (e == null) { e = new BeforeSceneLoadedEventArgs(sceneName, mode, async); } else { e.SceneName = sceneName; e.Mode = mode; e.AsyncHandle = async; } d(this, e); _beforeArgs = e; _beforeArgs.SceneName = null; _beforeArgs.Mode = default(LoadSceneMode); _beforeArgs.AsyncHandle = null; }