public SceneMetadata(int _buildIndex, string _name, string _path, int _sceneRing) { buildIndex = _buildIndex; name = _name; path = _path; sceneRing = (SceneRing)_sceneRing; }
/// <summary> /// Produce a method that compares to the given SceneRing bitmask. /// If extendedScene.metadata.sceneRing is in that bitmask and isn't the active scene in its ring, /// fire off the given action. /// </summary> public static Action <ExtendedScene> InRingsAndInactive(SceneRing comparison, Action <ExtendedScene> action) { return((extendedScene) => { if ((comparison & extendedScene.metadata.sceneRing) == comparison && Instance.GetActiveScene(extendedScene.metadata.sceneRing) != extendedScene) { action(extendedScene); } }); }
/// <summary> /// Produce a method that compares to the given SceneRing bitmask. /// If extendedScene.metadata.sceneRing is in that bitmask, fire off the given action. /// </summary> public static Action <ExtendedScene> InRings(SceneRing comparison, Action <ExtendedScene> action) { return((extendedScene) => { if ((comparison & extendedScene.metadata.sceneRing) == comparison) { action(extendedScene); } }); }
/// <summary> /// Get all scene metadata entries for the given single ring. /// </summary> private SceneMetadata[] GetAllMetadataEntriesForRing(SceneRing sceneRing) { sceneMetadataBufferList.Clear(); for (int i = 0; i < SceneDatatable.metadata.Length; i++) { if (SceneDatatable.metadata[i].sceneRing == SceneRing.GlobalScenes) { sceneMetadataBufferList.Add(SceneDatatable.metadata[i]); } } return(sceneMetadataBufferList.ToArray()); }
/// <summary> /// Gets all scenes - loaded or unloaded - in the specified rings. /// </summary> public ExtendedScene[] GetAllScenesInRings(SceneRing ring) { scenesBufferList.Clear(); for (int r = 1; r > int.MinValue; r = r << 1) { SceneRing testRing = (SceneRing)r; if ((ring & testRing) == testRing) { ExtendedScene[] scenes = scenesBySceneRings[testRing]; for (int s = 0; s < scenes.Length; s++) { scenesBufferList.Add(scenes[s]); } } } return(scenesBufferList.ToArray()); }
public DatatableEntry(int i) { buildIndex = i; convertedPath = SceneUtility.GetScenePathByBuildIndex(i); deconvertedPath = ExtendedScene.DeconvertPath(convertedPath); string[] substrings = deconvertedPath.Split('/'); sceneName = substrings[substrings.Length - 1]; sceneRing = SceneRing.None; for (int r = 1; r > int.MinValue; r = r << 1) { if (deconvertedPath.Contains("/" + (SceneRing)r + "/" + sceneName)) { sceneRing = (SceneRing)r; break; } } }
/// <summary> /// MonoBehaviour.Awake() /// </summary> void Awake() { SceneRing[] rings = (SceneRing[])Enum.GetValues(typeof(SceneRing)); timing = gameObject.AddComponent <Timing>(); currentLoadingOps = new List <AsyncOperation>(32); extendedScenesArray = new ExtendedScene[SceneDatatable.metadata.Length]; loadedScenes = new List <ExtendedScene>(32); scenesToLoad = new Queue <ExtendedScene>(32); scenesToUnload = new Queue <ExtendedScene>(32); scenesBufferList = new List <ExtendedScene>(128); sceneMetadataBufferList = new List <SceneMetadata>(128); lastScenesActiveInRings = new Dictionary <SceneRing, ExtendedScene>(rings.Length); scenesBySceneRings = new Dictionary <SceneRing, ExtendedScene[]>(rings.Length); Action onceOnline = () => { for (int r = 0; r < rings.Length; r++) { SceneRing ring = rings[r]; scenesBufferList.Clear(); for (int s = 0; s < SceneDatatable.metadata.Length; s++) { ExtendedScene extendedScene = GetExtendedScene(s); if (extendedScene.metadata.sceneRing == ring) { scenesBufferList.Add(extendedScene); } } scenesBySceneRings[ring] = scenesBufferList.ToArray(); lastScenesActiveInRings[ring] = null; } LoadGlobalScenes(); SceneManager.activeSceneChanged += (sceneA, sceneB) => { SyncActiveScene(); }; }; timing.RunCoroutineOnInstance(_WaitUntilOnline(onceOnline)); }
/// <summary> /// Gets the last active scene in the given scene ring. /// </summary> public ExtendedScene GetActiveScene(SceneRing ring) { return(lastScenesActiveInRings[ring]); }