예제 #1
0
        static IEnumerator CollectSceneSettings(string myPath, string theirPath)
        {
            yield return(null);

            EditorSceneManager.OpenScene(myPath);
            SceneData.Capture(true);

            yield return(null);

            EditorSceneManager.OpenScene(theirPath);
            SceneData.Capture(false);
        }
예제 #2
0
 internal void SwitchToAssetMode()
 {
     foreach (AvatarEditor.SceneStateCache current in this.m_SceneStates)
     {
         if (!(current.view == null))
         {
             current.view.m_SceneViewState.showFog            = current.state.showFog;
             current.view.m_SceneViewState.showFlares         = current.state.showFlares;
             current.view.m_SceneViewState.showMaterialUpdate = current.state.showMaterialUpdate;
             current.view.m_SceneViewState.showSkybox         = current.state.showSkybox;
         }
     }
     this.m_EditMode = AvatarEditor.EditMode.Stopping;
     this.DestroyEditor();
     this.ChangeInspectorLock(this.m_InspectorLocked);
     if (!EditorApplication.isUpdating && !Unsupported.IsDestroyScriptableObject(this))
     {
         string currentScene = EditorApplication.currentScene;
         if (currentScene.Length <= 0)
         {
             if (this.m_UserFileName.Length > 0)
             {
                 EditorApplication.OpenScene(this.m_UserFileName);
             }
             else
             {
                 EditorApplication.NewScene();
             }
         }
     }
     else
     {
         if (Unsupported.IsDestroyScriptableObject(this))
         {
             EditorApplication.CallbackFunction CleanUpSceneOnDestroy = null;
             string userFileName = this.m_UserFileName;
             CleanUpSceneOnDestroy = delegate
             {
                 string currentScene2 = EditorApplication.currentScene;
                 if (currentScene2.Length <= 0)
                 {
                     if (userFileName.Length > 0)
                     {
                         EditorApplication.OpenScene(userFileName);
                     }
                     else
                     {
                         EditorApplication.NewScene();
                     }
                 }
                 EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Remove(EditorApplication.update, CleanUpSceneOnDestroy);
             };
             EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.update, CleanUpSceneOnDestroy);
         }
     }
     this.m_GameObject = null;
     this.m_ModelBones = null;
     this.SelectAsset();
     if (!this.m_CameFromImportSettings)
     {
         this.m_EditMode = AvatarEditor.EditMode.NotEditing;
     }
 }
예제 #3
0
 public static void BakeMultipleScenes(string[] paths)
 {
     if (paths.Length != 0)
     {
         for (int i = 0; i < paths.Length; i++)
         {
             for (int k = i + 1; k < paths.Length; k++)
             {
                 if (paths[i] == paths[k])
                 {
                     throw new Exception("no duplication of scenes is allowed");
                 }
             }
         }
         SetLoadLevelForMultiLevelBake(true);
         string currentScene = EditorApplication.currentScene;
         bool   isSceneDirty = false;
         if (string.IsNullOrEmpty(currentScene))
         {
             isSceneDirty = EditorApplication.isSceneDirty;
             EditorApplication.SaveScene("Temp/MultiLevelBakeTemp.unity", true);
         }
         else
         {
             EditorApplication.SaveScene();
         }
         EditorApplication.OpenScene(paths[0]);
         for (int j = 1; j < paths.Length; j++)
         {
             EditorApplication.OpenSceneAdditive(paths[j]);
         }
         giWorkflowMode = GIWorkflowMode.OnDemand;
         BakeMultipleScenes_Internal(paths);
         foreach (UnityEngine.Object obj2 in AssetDatabase.LoadAllAssetsAtPath(Path.GetDirectoryName(paths[0]) + "/" + Path.GetFileNameWithoutExtension(paths[0]) + "/LightmapSnapshot.asset"))
         {
             LightmapSnapshot snapshot = obj2 as LightmapSnapshot;
             if (snapshot != null)
             {
                 EditorApplication.OpenScene(AssetDatabase.GUIDToAssetPath(snapshot.sceneGUID));
                 giWorkflowMode = GIWorkflowMode.OnDemand;
                 if (lightmapSnapshot != snapshot)
                 {
                     lightmapSnapshot = snapshot;
                     EditorApplication.SaveScene();
                 }
             }
         }
         SetLoadLevelForMultiLevelBake(false);
         if (string.IsNullOrEmpty(currentScene))
         {
             EditorApplication.OpenScene("Temp/MultiLevelBakeTemp.unity");
             EditorApplication.currentScene = string.Empty;
             if (isSceneDirty)
             {
                 EditorApplication.MarkSceneDirty();
             }
         }
         else
         {
             EditorApplication.OpenScene(currentScene);
         }
     }
 }
예제 #4
0
        void MergeScenes(string myPath, string theirPath)
        {
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
            var newScene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene);
            var myScene  = EditorSceneManager.OpenScene(myPath, OpenSceneMode.Additive);
#else
#if UNITY_5
            EditorApplication.NewEmptyScene();
#else
            EditorApplication.NewScene();
            var _allObjects = (GameObject[])Resources.FindObjectsOfTypeAll(typeof(GameObject));
            foreach (var obj in _allObjects)
            {
                if (obj.transform.parent == null && PrefabUtility.GetPrefabType(obj) != PrefabType.Prefab &&
                    PrefabUtility.GetPrefabType(obj) != PrefabType.ModelPrefab &&
                    obj.hideFlags == 0)                        //Want a better way to filter out "internal" objects
                {
                    DestroyImmediate(obj);
                }
            }
#endif
            EditorApplication.OpenSceneAdditive(myPath);
#endif

            var split = myPath.Split('/');
            myContainerName  = split[split.Length - 1].Replace(".unity", "");
            this.myContainer = new GameObject {
                name = myContainerName
            };
            var myContainer = this.myContainer;
            Undo.RegisterCreatedObjectUndo(myContainer, "UniMerge");

            var myTransform = myContainer.transform;
            var allObjects  = (GameObject[])Resources.FindObjectsOfTypeAll(typeof(GameObject));

            foreach (var obj in allObjects)
            {
                if (obj.transform.parent == null && PrefabUtility.GetPrefabType(obj) != PrefabType.Prefab &&
                    PrefabUtility.GetPrefabType(obj) != PrefabType.ModelPrefab &&
                    obj.hideFlags == 0)                        //Want a better way to filter out "internal" objects
                {
                    obj.transform.parent = myTransform;
                }
            }

#if UNITY_5_3 || UNITY_5_3_OR_NEWER
            SceneManager.MergeScenes(myScene, newScene);
#endif

#if UNITY_5_3 || UNITY_5_3_OR_NEWER
            var theirScene = EditorSceneManager.OpenScene(theirPath, OpenSceneMode.Additive);
            SceneManager.MergeScenes(theirScene, newScene);
#else
            EditorSceneManager.OpenSceneAdditive(theirPath);
#endif

            split = theirPath.Split('/');
            theirContainerName = split[split.Length - 1].Replace(".unity", "");

            this.theirContainer = new GameObject {
                name = theirContainerName
            };
            var theirContainer = this.theirContainer;
            Undo.RegisterCreatedObjectUndo(theirContainer, "UniMerge");

            allObjects = (GameObject[])Resources.FindObjectsOfTypeAll(typeof(GameObject));

            foreach (var obj in allObjects)
            {
                if (obj.transform.parent == null && obj.name != myContainerName &&
                    PrefabUtility.GetPrefabType(obj) != PrefabType.Prefab &&
                    PrefabUtility.GetPrefabType(obj) != PrefabType.ModelPrefab &&
                    obj.hideFlags == 0)                        //Want a better way to filter out "internal" objects
                {
                    obj.transform.parent = theirContainer.transform;
                }
            }
        }