Ejemplo n.º 1
0
 internal void SwitchToAssetMode()
 {
     foreach (SceneStateCache cache in this.m_SceneStates)
     {
         if (cache.view != null)
         {
             cache.view.m_SceneViewState.showFog            = cache.state.showFog;
             cache.view.m_SceneViewState.showFlares         = cache.state.showFlares;
             cache.view.m_SceneViewState.showMaterialUpdate = cache.state.showMaterialUpdate;
             cache.view.m_SceneViewState.showSkybox         = cache.state.showSkybox;
         }
     }
     this.m_EditMode = EditMode.Stopping;
     this.DestroyEditor();
     this.ChangeInspectorLock(this.m_InspectorLocked);
     if (!EditorApplication.isUpdating && !Unsupported.IsDestroyScriptableObject(this))
     {
         if (EditorApplication.currentScene.Length <= 0)
         {
             if (this.m_UserFileName.Length > 0)
             {
                 EditorApplication.OpenScene(this.m_UserFileName);
             }
             else
             {
                 EditorApplication.NewScene();
             }
         }
     }
     else if (Unsupported.IsDestroyScriptableObject(this))
     {
Ejemplo n.º 2
0
        internal void SwitchToEditMode()
        {
            this.m_EditMode = AvatarEditor.EditMode.Starting;
            this.ChangeInspectorLock(true);
            this.m_UserFileName = EditorApplication.currentScene;
            EditorApplication.NewScene();
            this.m_GameObject = UnityEngine.Object.Instantiate <GameObject>(this.prefab);
            if (base.serializedObject.FindProperty("m_OptimizeGameObjects").boolValue)
            {
                AnimatorUtility.DeoptimizeTransformHierarchy(this.m_GameObject);
            }
            Animator component = this.m_GameObject.GetComponent <Animator>();

            if (component != null && component.runtimeAnimatorController == null)
            {
                AnimatorController animatorController = new AnimatorController();
                animatorController.hideFlags = HideFlags.DontSave;
                animatorController.AddLayer("preview");
                component.runtimeAnimatorController = animatorController;
            }
            Dictionary <Transform, bool> modelBones = AvatarSetupTool.GetModelBones(this.m_GameObject.transform, true, null);

            AvatarSetupTool.BoneWrapper[] humanBones = AvatarSetupTool.GetHumanBones(base.serializedObject, modelBones);
            this.m_ModelBones      = AvatarSetupTool.GetModelBones(this.m_GameObject.transform, false, humanBones);
            Selection.activeObject = this.m_GameObject;
            UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll(typeof(SceneHierarchyWindow));
            for (int i = 0; i < array.Length; i++)
            {
                SceneHierarchyWindow sceneHierarchyWindow = (SceneHierarchyWindow)array[i];
                sceneHierarchyWindow.SetExpandedRecursive(this.m_GameObject.GetInstanceID(), true);
            }
            this.CreateEditor();
            this.m_EditMode    = AvatarEditor.EditMode.Editing;
            this.m_SceneStates = new List <AvatarEditor.SceneStateCache>();
            foreach (SceneView sceneView in SceneView.sceneViews)
            {
                this.m_SceneStates.Add(new AvatarEditor.SceneStateCache
                {
                    state = new SceneView.SceneViewState(sceneView.m_SceneViewState),
                    view  = sceneView
                });
                sceneView.m_SceneViewState.showFlares         = false;
                sceneView.m_SceneViewState.showMaterialUpdate = false;
                sceneView.m_SceneViewState.showFog            = false;
                sceneView.m_SceneViewState.showSkybox         = false;
                sceneView.FrameSelected();
            }
        }
Ejemplo n.º 3
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;
     }
 }
Ejemplo n.º 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;
                }
            }
        }