private void ClearParticleFactoryScene(PlayModeStateChange obj) { if (poolScene.IsValid()) { EditorSceneManager.UnloadSceneAsync(poolScene); } }
private static void RemoveBrokenEntityReferences(UnityEngine.SceneManagement.Scene scene) { if (!scene.isLoaded || !scene.IsValid()) { return; } using (var pooledToDelete = ListPool <EntityReference> .GetDisposable()) using (var pooledRoots = ListPool <GameObject> .GetDisposable()) { var toDelete = pooledToDelete.List; var roots = pooledRoots.List; scene.GetRootGameObjects(roots); foreach (var root in roots) { using (var pooledReferences = ListPool <EntityReference> .GetDisposable()) { var references = pooledReferences.List; root.GetComponentsInChildren(true, references); toDelete.AddRange(references.Where(r => r.Guid == Guid.Empty)); } } Delete(toDelete); } }
int GetSceneDirtyID(Scene scene) { if (scene.IsValid()) { return((int)m_GetDirtyIDMethod.Invoke(scene, null)); } else { return(-1); } }
private void LoadUnityScratchPadScene() { if ((!m_Scene.isLoaded || !m_Scene.IsValid()) && !Bridge.EditorApplication.IsQuitting) { m_Scene = GetOrGenerateScratchPad(); } // Make sure the scratch pad is clean if we somehow have saved gameObjects. foreach (var obj in m_Scene.GetRootGameObjects()) { Object.DestroyImmediate(obj); } }
private void RefreshSceneOrder() { if (m_SceneOrder.Count > 0) { string maxSceneName = null; int maxSceneOrder = 0; foreach (KeyValuePair <string, int> sceneOrder in m_SceneOrder) { if (SceneIsLoading(sceneOrder.Key)) { continue; } if (maxSceneName == null) { maxSceneName = sceneOrder.Key; maxSceneOrder = sceneOrder.Value; continue; } if (sceneOrder.Value > maxSceneOrder) { maxSceneName = sceneOrder.Key; maxSceneOrder = sceneOrder.Value; } } if (maxSceneName == null) { SetActiveScene(m_GameFrameworkScene); return; } UnityEngine.SceneManagement.Scene scene = UnityEngine.SceneManagement.SceneManager.GetSceneByName(GetSceneName(maxSceneName)); if (!scene.IsValid()) { Log.Error("Active scene '{0}' is invalid.", maxSceneName); return; } SetActiveScene(scene); } else { SetActiveScene(m_GameFrameworkScene); } }
/// <summary> /// 游戏框架组件初始化。 /// </summary> protected override void Awake() { base.Awake(); m_SceneMethods = CentorPivot.This.GetComponent <SceneComponent>(); if (m_SceneMethods == null) { Log.Fatal("Scene manager is invalid."); return; } m_SceneMethods.LoadSceneSuccess += OnLoadSceneSuccess; m_SceneMethods.LoadSceneFailure += OnLoadSceneFailure; if (m_EnableLoadSceneUpdateEvent) { m_SceneMethods.LoadSceneUpdate += OnLoadSceneUpdate; } if (m_EnableLoadSceneDependencyAssetEvent) { m_SceneMethods.LoadSceneDependencyAsset += OnLoadSceneDependencyAsset; } m_SceneMethods.UnloadSceneSuccess += OnUnloadSceneSuccess; m_SceneMethods.UnloadSceneFailure += OnUnloadSceneFailure; m_GameFrameworkScene = UnityEngine.SceneManagement.SceneManager.GetSceneAt(ApplicationHelper.SceneId); if (!m_GameFrameworkScene.IsValid()) { Log.Fatal("Game Framework scene is invalid."); return; } if (EventComponent.This == null) { Log.Fatal("Event component is invalid."); return; } m_SceneMethods.SetResourceManager(CentorPivot.This.GetComponent <ResourceComponent>()); //Instantiation = this; }
static StackObject *IsValid_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); UnityEngine.SceneManagement.Scene instance_of_this_method = (UnityEngine.SceneManagement.Scene) typeof(UnityEngine.SceneManagement.Scene).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); var result_of_this_method = instance_of_this_method.IsValid(); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); __intp.Free(ptr_of_this_method); __ret->ObjectType = ObjectTypes.Integer; __ret->Value = result_of_this_method ? 1 : 0; return(__ret + 1); }
//----------------------------------------------------------- // シーンをロードまたは加算する(同期版) private bool LoadOrAdd_Private(string tName, Type tType, UnityEngine.Object[] rTarget, string tTargetName, string tLabel, System.Object tValue, UnityEngine.SceneManagement.LoadSceneMode tMode, bool tHistory) { if (string.IsNullOrEmpty(tName) == true) { return(false); } if (string.IsNullOrEmpty(tLabel) == false) { SetParameter_Private(tLabel, tValue); } if (tMode == UnityEngine.SceneManagement.LoadSceneMode.Single) { // ロードの場合は履歴に追加する previousName = GetActiveName(); if (tHistory == true) { history.Add(tName); } } UnityEngine.SceneManagement.SceneManager.LoadScene(tName, tMode); //------------------------------------------------------------------------------------------ UnityEngine.SceneManagement.Scene tScene = UnityEngine.SceneManagement.SceneManager.GetSceneByName(tName); if (tScene.IsValid() == false || tScene.isLoaded == false) { return(false); } if (tType != null && rTarget != null && rTarget.Length > 0) { GetInstance_Private(tScene, tType, rTarget, tTargetName, null); } return(true); }
/// <summary> /// 移动场景 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="t_GameObjectList"></param> /// <param name="t_SceneName"></param> public void MoveToScene <T>(List <T> t_GameObjectList, string t_SceneName) { UnityEngine.SceneManagement.Scene t_TargetScene = UnityEngine.SceneManagement.SceneManager.GetSceneByName(t_SceneName); if (t_TargetScene.IsValid()) { int t_GameObjectCount = t_GameObjectList.Count; for (int i = 0; i < t_GameObjectList.Count; i++) { UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(t_GameObjectList[i] as GameObject, t_TargetScene); if (null != MoveToUpdateEventHandler) { MoveToUpdateEventHandler(this, new SceneEventArgs() { SceneName = t_SceneName, Process = (0 == i ? 0 : i / t_GameObjectCount) * 100, Scene = t_TargetScene }); } } UnityEngine.SceneManagement.SceneManager.SetActiveScene(t_TargetScene); if (null != MoveToSuccessEventHandler) { MoveToSuccessEventHandler(this, new SceneEventArgs() { SceneName = t_SceneName, Process = 100f, Scene = t_TargetScene }); } } else { //不是一个有效的场景 if (null != MoveToFailureEventHandler) { MoveToFailureEventHandler(this, new SceneEventArgs() { SceneName = t_SceneName, Process = 0f, Scene = t_TargetScene }); } } }
// シーンをロードまたは加算する(非同期版) private IEnumerator LoadOrAddAsync_Private(string tName, Type tType, UnityEngine.Object[] rTarget, string tTargetName, string tLabel, System.Object tValue, UnityEngine.SceneManagement.LoadSceneMode tMode, bool tHistory, Request tRequest) { if (string.IsNullOrEmpty(tName) == true) { yield break; } //---------------------------------------------------------- if (tType != null) { // 指定の型のコンポーネントが存在する場合はそれが完全に消滅するまで待つ while (true) { if (GameObject.FindObjectOfType(tType) == null) { break; } yield return(null); } } //---------------------------------------------------------- if (string.IsNullOrEmpty(tLabel) == false) { SetParameter_Private(tLabel, tValue); } if (tMode == UnityEngine.SceneManagement.LoadSceneMode.Single) { // ロードの場合は履歴に追加する previousName = GetActiveName(); if (tHistory == true) { history.Add(tName); } } yield return(UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(tName, tMode)); //------------------------------------------------------------------------------------------ UnityEngine.SceneManagement.Scene tScene = UnityEngine.SceneManagement.SceneManager.GetSceneByName(tName); if (tScene.IsValid() == false) { if (tRequest != null) { tRequest.error = "Could not load"; } yield break; } // シーンの展開が完了するのを待つ while (tScene.isLoaded == false) { yield return(null); } if (tType != null && rTarget != null && rTarget.Length > 0) { GetInstance_Private(tScene, tType, rTarget, tTargetName, tRequest); } if (tRequest != null) { tRequest.isDone = true; } }
static TapjoyUnity.Internal.UnityCompat.SceneCompat Wrap(UnityEngine.SceneManagement.Scene scene) { return(new TapjoyUnity.Internal.UnityCompat.SceneCompat(scene, scene.IsValid(), scene.buildIndex, scene.name, scene.path)); }