private IEnumerator loadSceneAsync(string sceneName, int id) { //load scene a AsyncOperation async = Application.LoadLevelAdditiveAsync(sceneName); yield return(async); //asdfasdf ToolbeltManager[] tbms = FindObjectsOfType(typeof(ToolbeltManager)) as ToolbeltManager[]; ToolbeltManager tm = null; foreach (ToolbeltManager tbm in tbms) { if (!tbm.assignedUniqueID && tbm.gameObject.name == "__" + sceneName) { tm = tbm; tm.assignUniqueID(id); break; } } if (tm == null) { throw new MissingReferenceException("Component incorrectly named or does not include a Scene script: " + sceneName); } else { tm.JustFinishedAsyncLoad(this); this.DoneLoadOtherScene(tm); } }
//called when another object finished loading by this tm protected override void DoneLoadOtherScene(ToolbeltManager tm) { if (tm.getUniqueID() == this.scene2id) { Debug.Log ("scene2 loaded!"); tm.ActivateSceneParent(); } //you can identify the other tm via its uniqueID. }
void SwitchEyes() { ToolbeltManager tm = ToolbeltManager.FirstInstance; // Remove previous eye layer from culling mask this.camera.cullingMask = this.camera.cullingMask & ~(1 << tm.GetStereoLayer(this.curStereo)); this.curStereo = (this.curStereo == StereoMode.LEFT) ? StereoMode.RIGHT : StereoMode.LEFT; this.camera.cullingMask = this.camera.cullingMask | (1 << tm.GetStereoLayer(this.curStereo)); //Debug.Log(Time.frameCount.ToString() + " " + this.camera.cullingMask.ToString()); }
void Awake() { this.PreAwakeSubclass(); // The first ToolbeltManager to start up will be stored if (instance == null) { instance = this; this.mediaLoader = new icMediaLoader(this.concurrentMediaLoads, useBink); this.soundLoader = new icMediaLoader(this.concurrentMediaLoads, false); if (imageCacheMBs > 0) { imageCacher = new icImageCacher(imageCacheMBs, imageCacheGraceTime); } this.assignUniqueID(ToolbeltManager.GenerateUniqueID()); this.ActivateSceneParent(); } this.AwakeSubclass(); // TODO: don't initialise singletons if being loaded by another scene // Scene loading code should look for ToolbeltManager and set // parameters appropriately }
//called when another object finished loading by this tm protected virtual void DoneLoadOtherScene(ToolbeltManager tm) { //you can identify the other tm via its uniqueID. }
protected void JustFinishedAsyncLoad(ToolbeltManager tm) { //called when this object was loaded async by another tbm this.masterManager = tm; this.transform.parent = tm.transform; }
void Awake() { this.PreAwakeSubclass(); // The first ToolbeltManager to start up will be stored if (instance == null) { instance = this; this.mediaLoader = new icMediaLoader(this.concurrentMediaLoads, useBink); this.soundLoader = new icMediaLoader(this.concurrentMediaLoads, false); if (imageCacheMBs > 0) imageCacher = new icImageCacher(imageCacheMBs, imageCacheGraceTime); this.assignUniqueID(ToolbeltManager.GenerateUniqueID()); this.ActivateSceneParent(); } this.AwakeSubclass(); // TODO: don't initialise singletons if being loaded by another scene // Scene loading code should look for ToolbeltManager and set // parameters appropriately }
protected void JustFinishedAsyncLoad(ToolbeltManager tm) { //called when this object was loaded async by another tbm this.masterManager = tm; this.transform.parent = tm.transform; }
//called when another object finished loading by this tm protected virtual void DoneLoadOtherScene(ToolbeltManager tm) { //you can identify the other tm via its uniqueID. }