private void OnSceneLoadComplete(object o) { isLoadingScene = false; SceneVO vo = o as SceneVO; vo.loading = false; // Debug.LogError("loading scene finish" + msg.m_scenename + Time.realtimeSinceStartup.ToString()); //Application.LoadLevel(_msg.m_scenename); //GameManager.Instance.CurrentScene = vo; GUIManager.CloseAllUI(); GUIManager.HideLoadingUI(); GameProxy.Instance.RealEnterScene(vo.sceneName, vo.scenetype); //卸载场景assetboundle AssetManager.UnloadAssetBundle(vo.abname); if (vo.scenetype == EScene.PVE) { GameManager.Instance.LoadPrefab("player001"); GameManager.Instance.LoadPrefab("zuqiuchang"); GameManager.Instance.LoadPrefab("goalmesh_left"); GameManager.Instance.LoadPrefab("goalmesh_right"); GameManager.Instance.LoadPrefab("goalkeeper_left"); GameManager.Instance.LoadPrefab("goalkeeper_right"); } }
public override void Execute(INotification notification) { SceneVO msg = notification.Body as SceneVO; GUIManager.ShowLoadingUI(); if (NotificationID.CHANGE_SCENE == notification.Name) { if (isLoadingScene) { Debug.LogError("已经在切换场景中。。。。"); return; } if (msg.scenetype == EScene.PVE) { } isLoadingScene = true; AssetManager.UnloadAllCacheRes(true); // Debug.LogError("loading scene start" + Time.realtimeSinceStartup.ToString()); Facade.SendNotification(NotificationID.UPDATE_SCENE_MEDIATOR, msg); ResourceManager.Instance.LoadScene(msg.sceneName, false, OnSceneLoadComplete, msg); } }
private void OnSceneLoadComplete(object o) { isLoadingScene = false; SceneVO vo = o as SceneVO; vo.loading = false; OnInit(vo); }
private void OnLoadingSceneLoad(object o) { isLoadingScene = false; Debug.LogError("loading scene finish" + Time.realtimeSinceStartup); SceneVO vo = o as SceneVO; vo.loading = true; GameManager.Instance.CurrentScene = vo; // AssetManager.UnloadAssetBundle("s_loading"); AssetManager.UnloadAllCacheRes(true); Facade.SendNotification(NotificationID.UPDATE_SCENE_MEDIATOR, vo); Debug.LogError("loading scene start" + vo.sceneName + Time.realtimeSinceStartup.ToString()); ResourceManager.Instance.LoadScene(vo.sceneName, true, OnSceneLoadComplete, vo); }
private void OnInit(SceneVO vo) { if (vo.scenetype != EScene.MAINCITY) { GameProxy.Instance.RealEnterScene(vo.sceneName, vo.scenetype); } AssetManager.UnloadAssetBundle(vo.abname); GameManager.Instance.ResetLoadData(); if (vo.scenetype == EScene.PVE) { GameManager.Instance.LoadPrefab("zuqiuchang"); GameManager.Instance.LoadPrefab("player001"); GameManager.Instance.LoadPrefab("goalmesh_left"); GameManager.Instance.LoadPrefab("goalmesh_right"); GameManager.Instance.LoadPrefab("goalkeeper_left"); GameManager.Instance.LoadPrefab("goalkeeper_right"); } //else //GUIManager.HideLoadingUI(); }
public override void Execute(INotification notification) { SceneVO msg = notification.Body as SceneVO; if (NotificationID.CHANGE_SCENE == notification.Name) { if (isLoadingScene) { Debug.LogError("已经在切换场景中。。。。"); return; } //GUIManager.CloseAllUI(true, true); if (msg.scenetype == EScene.PVP) { } else { GUIManager.CloseAllUI(true); AssetManager.UnloadAllCacheRes(true); } //GUIManager.ShowLoadingUI(); isLoadingScene = true; Facade.SendNotification(NotificationID.UPDATE_SCENE_MEDIATOR, msg); ResourceManager.Instance.LoadScene(msg.sceneName, false, OnSceneLoadComplete, msg); if (msg.scenetype == EScene.MAINCITY) { GameProxy.Instance.RealEnterScene(msg.sceneName, msg.scenetype); } } }
void OnGUI() { EditorGUILayout.BeginVertical(); findSprite = EditorGUILayout.ObjectField("查找 Sprite", findSprite, typeof(Sprite), false) as Sprite; replaceSprite = EditorGUILayout.ObjectField("替换 Sprite", replaceSprite, typeof(Sprite), false) as Sprite; GUILayout.Box("查找目录:(用';'分隔)"); sceneFolderStr = GUILayout.TextArea(sceneFolderStr, 500, GUILayout.MinHeight(50)); sceneFolderStr = sceneFolderStr.Trim(); sceneFolders = sceneFolderStr.Split(';'); isSaveScene = GUILayout.Toggle(isSaveScene, "是否保存场景"); if (findSprite != null) { if (GUILayout.Button("查找")) { sceneList.Clear(); if (!EditorApplication.SaveCurrentSceneIfUserWantsTo()) { return; } string editorScenePath = EditorApplication.currentScene; // string[] guids = AssetDatabase.FindAssets ("t:scene", new string[] {"Assets/Game/Arts_Modules", "Assets/Game/Scenes"}); string[] guids = AssetDatabase.FindAssets("t:scene", sceneFolders); string activePath = AssetDatabase.GetAssetPath(findSprite); Debug.Log("activePath=" + activePath); foreach (string guid in guids) { string scenePath = AssetDatabase.GUIDToAssetPath(guid); SceneVO sceneVO = new SceneVO(); sceneVO.path = scenePath; //打开场景 EditorApplication.OpenScene(scenePath); //获取场景中的所有游戏对象 Image[] images = (Image[])FindObjectsOfTypeAll(typeof(Image)); foreach (Image image in images) { if (image.sprite == null) { continue; } string path = AssetDatabase.GetAssetPath(image.sprite); if (path == activePath) { ImageVO imageVO = new ImageVO(); imageVO.path = GetGameObjectPath(image.gameObject); imageVO.scene = sceneVO; sceneVO.list.Add(imageVO); PrefabType prefabType = PrefabUtility.GetPrefabType(image.gameObject); if (prefabType == PrefabType.PrefabInstance) { UnityEngine.Object parentObject = PrefabUtility.GetPrefabParent(image.gameObject); imageVO.prefabPath = AssetDatabase.GetAssetPath(parentObject); } else if (prefabType == PrefabType.Prefab) { imageVO.prefabPath = AssetDatabase.GetAssetPath(image.gameObject); } } } if (sceneVO.list.Count > 0) { sceneList.Add(sceneVO); } } if (!string.IsNullOrEmpty(editorScenePath)) { EditorApplication.OpenScene(editorScenePath); } } if (replaceSprite != null) { if (GUILayout.Button("替换所有(注意:确认无误后再点击)")) { sceneList.Clear(); if (!EditorApplication.SaveCurrentSceneIfUserWantsTo()) { return; } string editorScenePath = EditorApplication.currentScene; // string[] guids = AssetDatabase.FindAssets ("t:scene", new string[] {"Assets/Game/Arts_Modules", "Assets/Game/Scenes"}); string[] guids = AssetDatabase.FindAssets("t:scene", sceneFolders); string activePath = AssetDatabase.GetAssetPath(findSprite); Debug.Log("activePath=" + activePath); foreach (string guid in guids) { string scenePath = AssetDatabase.GUIDToAssetPath(guid); SceneVO sceneVO = new SceneVO(); sceneVO.path = scenePath; //打开场景 if (EditorApplication.SaveCurrentSceneIfUserWantsTo()) { EditorApplication.OpenScene(scenePath); //获取场景中的所有游戏对象 Image[] images = (Image[])FindObjectsOfTypeAll(typeof(Image)); foreach (Image image in images) { if (image.sprite == null) { continue; } string path = AssetDatabase.GetAssetPath(image.sprite); if (path == activePath) { ImageVO imageVO = new ImageVO(); imageVO.path = GetGameObjectPath(image.gameObject); imageVO.scene = sceneVO; sceneVO.list.Add(imageVO); PrefabType prefabType = PrefabUtility.GetPrefabType(image.gameObject); if (prefabType == PrefabType.PrefabInstance) { UnityEngine.Object parentObject = PrefabUtility.GetPrefabParent(image.gameObject); imageVO.prefabPath = AssetDatabase.GetAssetPath(parentObject); } else if (prefabType == PrefabType.Prefab) { imageVO.prefabPath = AssetDatabase.GetAssetPath(image.gameObject); } image.sprite = replaceSprite; } } if (sceneVO.list.Count > 0) { sceneList.Add(sceneVO); if (isSaveScene) { EditorApplication.SaveScene(); } } } } if (!string.IsNullOrEmpty(editorScenePath)) { if (EditorApplication.SaveCurrentSceneIfUserWantsTo()) { EditorApplication.OpenScene(editorScenePath); } } } } } GUILayout.Space(30); GUILayout.Box("搜索结果:"); scrollPos = EditorGUILayout.BeginScrollView(scrollPos); foreach (SceneVO sceneVO in sceneList) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(sceneVO.path)) { if (EditorApplication.SaveCurrentSceneIfUserWantsTo()) { EditorApplication.OpenScene(sceneVO.path); } } if (EditorApplication.currentScene == sceneVO.path) { if (replaceSprite != null && GUILayout.Button("替换", GUILayout.Width(50))) { //获取场景中的所有游戏对象 Image[] images = (Image[])FindObjectsOfTypeAll(typeof(Image)); string activePath = AssetDatabase.GetAssetPath(findSprite); foreach (Image image in images) { if (image.sprite == null) { continue; } string path = AssetDatabase.GetAssetPath(image.sprite); if (path == activePath) { image.sprite = replaceSprite; EditorUtility.SetDirty(image); } } if (isSaveScene) { EditorApplication.SaveScene(); } } } EditorGUILayout.EndHorizontal(); //------------------------- foreach (ImageVO imageVO in sceneVO.list) { EditorGUILayout.BeginHorizontal(); GUILayout.Label(imageVO.path); if (!string.IsNullOrEmpty(imageVO.prefabPath) && GUILayout.Button("Prefab", GUILayout.Width(50))) { Selection.activeGameObject = AssetDatabase.LoadAssetAtPath <GameObject>(imageVO.prefabPath); } if (GUILayout.Button("Find", GUILayout.Width(50))) { Debug.Log("imageVO.prefabPath = " + imageVO.prefabPath); if (EditorApplication.currentScene != sceneVO.path) { if (EditorApplication.SaveCurrentSceneIfUserWantsTo()) { EditorApplication.OpenScene(sceneVO.path); Selection.activeGameObject = GameObject.Find(imageVO.path); } } else { Selection.activeGameObject = GameObject.Find(imageVO.path); } } EditorGUILayout.EndHorizontal(); } GUILayout.Space(20); } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }