示例#1
0
    public void LoadSetupInclusive()
    {
        SceneSetup[] current  = EditorSceneManager.GetSceneManagerSetup();
        SceneSetup[] newSetup = new SceneSetup[current.Length + setup.Length];

        int newSetupIndex = 0;

        for (int i = 0; i < current.Length; i++)
        {
            newSetup[newSetupIndex] = current[i];
            newSetupIndex++;
        }
        for (int i = 0; i < setup.Length; i++)
        {
            newSetup[newSetupIndex] = new SceneSetup()
            {
                path     = setup[i].path,
                isLoaded = setup[i].isLoaded,
                isActive = false
            };
            newSetupIndex++;
        }

        EditorSceneManager.RestoreSceneManagerSetup(newSetup);
    }
示例#2
0
        void EnterSkinEditMode()
        {
            if (!editMode)
            {
                oldSelection = Selection.activeObject;
                if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
                {
                    editMode = true;
                    ActiveEditorTracker.sharedTracker.isLocked = true;

                    oldSetup  = EditorSceneManager.GetSceneManagerSetup();
                    editScene = EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);

                    if (skinMap.SourceTopology != null && skinMap.SourceTopology.input != null)
                    {
                        sourceObject = new GameObject("Source mesh", typeof(MeshRenderer), typeof(MeshFilter));
                        sourceObject.GetComponent <MeshRenderer>().material = standardMaterial;
                        sourceObject.GetComponent <MeshFilter>().sharedMesh = GameObject.Instantiate(skinMap.SourceTopology.input);
                        skinMap.sourceSkinTransform.Apply(sourceObject.transform);
                        Selection.activeObject = sourceObject;
                    }

                    if (skinMap.TargetMesh != null)
                    {
                        targetObject = new GameObject("Target mesh", typeof(MeshRenderer), typeof(MeshFilter));
                        targetObject.GetComponent <MeshRenderer>().material = standardMaterial;
                        targetObject.GetComponent <MeshFilter>().sharedMesh = GameObject.Instantiate(skinMap.TargetMesh);
                        skinMap.targetSkinTransform.Apply(targetObject.transform);
                        Selection.activeObject = targetObject;
                    }

                    SceneView.FrameLastActiveSceneView();
                }
            }
        }
示例#3
0
        static private void Execute(LightmapBakeMode lightmapBakeMode)
        {
            Undo.IncrementCurrentGroup();
            Undo.SetCurrentGroupName("Bake Lightmaps");

            // If no scenes are selected configure and bake combined lightmap for all open scenes
            var scenePathList = new List <string>();

            if (Selection.objects.Length > 0)
            {
                foreach (var sceneAsset in Selection.objects)
                {
                    scenePathList.Add(AssetDatabase.GetAssetPath(sceneAsset));
                }
            }
            else
            {
                var sceneSetupList = EditorSceneManager.GetSceneManagerSetup();
                foreach (var sceneSetup in sceneSetupList)
                {
                    scenePathList.Add(sceneSetup.path);
                }
            }

            EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();
            ApplyTo(lightmapBakeMode, scenePathList.ToArray());
        }
示例#4
0
        /// <summary>
        /// 生成烘焙数据
        /// </summary>
        public static void BakeGroupAsset(MapGroupAsset groupAsset)
        {
            //TODO:设置实时光照配置
            //保护现场
            SceneSetup[] sceneSetup = EditorSceneManager.GetSceneManagerSetup();

            //Setting
            for (int i = 0; i < 3; i++)
            {
                Scene s = EditorSceneManager.OpenScene(GetScenePath(groupAsset, i), OpenSceneMode.Single);
                {
                    Lightmapping.bakedGI    = false;
                    Lightmapping.realtimeGI = true;
                    LightmapEditorSettings.realtimeResolution = 4;
                }
                EditorSceneManager.SaveScene(s);
            }

            //恢复现场
            EditorSceneManager.RestoreSceneManagerSetup(sceneSetup);

            //Bake
            string[] paths = { GetScenePath(groupAsset, 0), GetScenePath(groupAsset, 1), GetScenePath(groupAsset, 2) };
            Lightmapping.BakeMultipleScenes(paths); //这个API是异步的!

            groupAsset.baked = true;
        }
        /// <summary>
        /// Updates Loader scene parameters to run the deck on start.
        /// </summary>
        /// <param name="deck">Slide Deck to use.</param>
        private static void updateLoaderScene(SlideDeck deck)
        {
            var sceneSetup = EditorSceneManager.GetSceneManagerSetup();
            var scene      = EditorSceneManager.OpenScene(SceneUtils.LoaderScenePath, OpenSceneMode.Single);
            var loader     = GameObject.FindObjectOfType <Loader>() as Loader;

            if (loader == null)
            {
                Debug.LogError("Failed to update Loader scene. Can't find Loader script");
                return;
            }

            var so = new SerializedObject(loader);

            so.Update();

            // Set properties.
            var prop = so.FindProperty("Properties");

            prop.objectReferenceValue = Properties.Instance;
            var d = so.FindProperty("Deck");

            d.objectReferenceValue = deck;

            so.ApplyModifiedProperties();

            EditorSceneManager.SaveScene(scene);
            EditorSceneManager.RestoreSceneManagerSetup(sceneSetup);
        }
示例#6
0
        // Returns true if succeeds without errors
        public static bool SaveThenRunPreserveSceneSetup(Action action)
        {
            if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
            {
                var originalSceneSetup = EditorSceneManager.GetSceneManagerSetup();

                try
                {
                    action();
                    return(true);
                }
                catch (Exception e)
                {
                    ModestTree.Log.ErrorException(e);
                    return(false);
                }
                finally
                {
                    EditorSceneManager.RestoreSceneManagerSetup(originalSceneSetup);
                }
            }
            else
            {
                return(false);
            }
        }
    void UpdateScenes(SceneReference _target)
    {
        var setups = EditorSceneManager.GetSceneManagerSetup();

        var newList = new List <MultipleScenesData>();

        foreach (var s in setups)
        {
            SceneAsset         scn       = AssetDatabase.LoadAssetAtPath <SceneAsset>(s.path);
            MultipleScenesData dataToAdd = null;
            foreach (var d in _target.linkingData.sceneDatas)
            {
                if (scn.name == d.SceneName)
                {
                    dataToAdd = d;
                    break;
                }
            }

            if (dataToAdd == null)
            {
                dataToAdd             = new MultipleScenesData();
                dataToAdd.sceneObject = scn;
            }

            newList.Add(dataToAdd);
        }

        Undo.RecordObject(_target.linkingData, "List Update");
        _target.linkingData.sceneDatas = newList;
        EditorUtility.SetDirty(_target.linkingData);
    }
示例#8
0
 void Init()
 {
     EditorSceneManager.SaveOpenScenes();
     currentScene = EditorSceneManager.GetSceneManagerSetup();
     EditorSceneManager.OpenScene("Assets/PuzzleEditor/PuzzleEditorScene.unity");
     parent = GameObject.Find("Puzzle Creator Parent").transform;
 }
示例#9
0
        public static bool ProcessScene(string sceneName, string processName, bool saveScenes, Action <UnityEngine.SceneManagement.Scene> customProcess)
        {
            bool Completed = true;

            SceneSetup[] sceneSetups = EditorSceneManager.GetSceneManagerSetup();
            if (saveScenes)
            {
                if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
                {
                    return(false);
                }
            }
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
            try
            {
                Scene scene = EditorSceneManager.OpenScene(EditorBuildSettings.scenes.First(x => x.path.Contains(sceneName)).path, OpenSceneMode.Single);
                customProcess(scene);
                if (saveScenes)
                {
                    EditorSceneManager.MarkSceneDirty(scene);
                    EditorSceneManager.SaveOpenScenes();
                    EditorSceneManager.CloseScene(scene, true);
                }
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
            }
            EditorUtility.ClearProgressBar();
            EditorSceneManager.RestoreSceneManagerSetup(sceneSetups);
            return(Completed);
        }
    static void SaveCurrentHierarchy(MultipleSceneSetting _data)
    {
        var setups = EditorSceneManager.GetSceneManagerSetup();

        var newList = new List <MultipleScenesData>();

        foreach (var s in setups)
        {
            SceneAsset         scn       = AssetDatabase.LoadAssetAtPath <SceneAsset>(s.path);
            MultipleScenesData dataToAdd = null;
            foreach (var d in _data.sceneDatas)
            {
                if (scn.name == d.SceneName)
                {
                    dataToAdd = d;
                    break;
                }
            }

            if (dataToAdd == null)
            {
                dataToAdd             = new MultipleScenesData();
                dataToAdd.sceneObject = scn;
            }

            newList.Add(dataToAdd);
        }

        Undo.RecordObject(_data, "List Update");
        _data.sceneDatas = newList;
        EditorUtility.SetDirty(_data);
    }
示例#11
0
    public static void SavesSetup()
    {
        var asset = ScriptableObject.CreateInstance <SceneManagerSetupAsset>();

        asset.SceneSetup = EditorSceneManager.GetSceneManagerSetup();
        AssetDatabase.CreateAsset(asset, k_SetupAssetPath);
    }
    static void OnPostProcessScene()
    {
        foreach (var sceneManager in EditorSceneManager.GetSceneManagerSetup())
        {
            var scenePath = sceneManager.path;

            var scene = SceneManager.GetSceneByPath(scenePath);

            var prefabName = string.Format("ScenePrefab({0})", scenePath);

            if (string.IsNullOrEmpty(scene.path))
            {
                continue;
            }

            if (GameObject.Find(prefabName) != null)
            {
                continue;
            }

            var prefab = GetScenePrefab(scenePath);

            if (prefab)
            {
                var go = PrefabUtility.InstantiatePrefab(prefab, scene);
                go.name = prefabName;
            }
        }
    }
示例#13
0
 /// <summary>
 ///   <para>Bakes an array of scenes.</para>
 /// </summary>
 /// <param name="paths">The path of the scenes that should be baked.</param>
 public static void BakeMultipleScenes(string[] paths)
 {
     if (paths.Length == 0)
     {
         return;
     }
     for (int index1 = 0; index1 < paths.Length; ++index1)
     {
         for (int index2 = index1 + 1; index2 < paths.Length; ++index2)
         {
             if (paths[index1] == paths[index2])
             {
                 throw new Exception("no duplication of scenes is allowed");
             }
         }
     }
     if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
     {
         return;
     }
     SceneSetup[] sceneManagerSetup = EditorSceneManager.GetSceneManagerSetup();
     EditorSceneManager.OpenScene(paths[0]);
     for (int index = 1; index < paths.Length; ++index)
     {
         EditorSceneManager.OpenScene(paths[index], OpenSceneMode.Additive);
     }
     Lightmapping.Bake();
     EditorSceneManager.SaveOpenScenes();
     EditorSceneManager.RestoreSceneManagerSetup(sceneManagerSetup);
 }
示例#14
0
        private static bool OpenNewScene(out SceneSetup[] previousSceneSetup)
        {
            previousSceneSetup = null;

            var sceneCount = SceneManager.sceneCount;

            var scene = SceneManager.GetSceneAt(0);
            var isSceneNotPersisted = string.IsNullOrEmpty(scene.path);

            if (sceneCount == 1 && isSceneNotPersisted)
            {
                EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Single);
                return(true);
            }
            RemoveUntitledScenes();

            // In case the user chose not to save the dirty scenes we reload them
            ReloadUnsavedDirtyScene();

            previousSceneSetup = EditorSceneManager.GetSceneManagerSetup();

            scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Additive);
            SceneManager.SetActiveScene(scene);

            return(true);
        }
示例#15
0
 public static void BakeMultipleScenes(string[] paths)
 {
     if (paths.Length == 0)
     {
         return;
     }
     for (int i = 0; i < paths.Length; i++)
     {
         for (int j = i + 1; j < paths.Length; j++)
         {
             if (paths[i] == paths[j])
             {
                 throw new Exception("no duplication of scenes is allowed");
             }
         }
     }
     if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
     {
         return;
     }
     SceneSetup[] sceneManagerSetup = EditorSceneManager.GetSceneManagerSetup();
     EditorSceneManager.OpenScene(paths[0]);
     for (int k = 1; k < paths.Length; k++)
     {
         EditorSceneManager.OpenScene(paths[k], OpenSceneMode.Additive);
     }
     Lightmapping.Bake();
     EditorSceneManager.SaveOpenScenes();
     EditorSceneManager.RestoreSceneManagerSetup(sceneManagerSetup);
 }
示例#16
0
 public static void Menu_StartGame()
 {
     if (!EditorApplication.isPlayingOrWillChangePlaymode && EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
     {
         if (!BloxEdGlobal.DataSpotCheck())
         {
             EditorUtility.DisplayDialog("Blox Game Systems", "The project does not seem to be playable yet. You need to run a data check via menu: Blox > Check Data", "OK");
         }
         else
         {
             try
             {
                 string contents = JsonUtility.ToJson(new ScenesSetupInfo
                 {
                     sceneSetup = EditorSceneManager.GetSceneManagerSetup()
                 });
                 File.WriteAllText(plyEdUtil.ProjectTempFolder + "BloxSceneSetup", contents);
             }
             catch
             {
             }
             EditorSceneManager.OpenScene(BloxEdGlobal.BootstrapScenePath, OpenSceneMode.Single);
             EditorPrefs.SetInt("Blox.playTestingMode", 2);
             EditorApplication.isPlaying = true;
         }
     }
 }
示例#17
0
        static bool ValidateWrapper(Action action)
        {
            if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
            {
                var originalSceneSetup = EditorSceneManager.GetSceneManagerSetup();

                try
                {
                    action();
                    return(true);
                }
                catch (Exception e)
                {
                    ModestTree.Log.ErrorException(e);
                    return(false);
                }
                finally
                {
                    EditorSceneManager.RestoreSceneManagerSetup(originalSceneSetup);
                }
            }
            else
            {
                UnityEngine.Debug.Log("Validation cancelled - All scenes must be saved first for validation to take place");
                return(false);
            }
        }
示例#18
0
        static bool ValidateInternal()
        {
            if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
            {
                var originalSceneSetup = EditorSceneManager.GetSceneManagerSetup();

                try
                {
                    ZenUnityEditorUtil.ValidateCurrentSceneSetup();
                    Log.Info("All scenes validated successfully");
                    return(true);
                }
                catch (Exception e)
                {
                    Log.ErrorException(e);
                    return(false);
                }
                finally
                {
                    EditorSceneManager.RestoreSceneManagerSetup(originalSceneSetup);
                }
            }
            else
            {
                Debug.Log("Validation cancelled - All scenes must be saved first for validation to take place");
                return(false);
            }
        }
    void OnGUI()
    {
        GUILayout.Box("To save the current Scene set up in the Hierarchy as a Scene Collection, enter a name below and click the Save Scene Collection button.");

        EditorGUILayout.Space();

        _newCollectionName = EditorGUILayout.TextField("Name", _newCollectionName);

        if (GUILayout.Button("Save Scene Collection"))
        {
            if (!AssetDatabase.LoadAssetAtPath <ScriptableObject>("Assets/SceneCollections/" + _newCollectionName + ".asset") ||
                EditorUtility.DisplayDialog("Warning", "A Scene collection by that name already exists. Do you want to overwrite it?", "Yes", "Cancel"))
            {
                SceneSetup[] setups = EditorSceneManager.GetSceneManagerSetup();
                if (_newCollectionName.Equals(""))
                {
                    _newCollectionName = "New Scene Collection";
                }
                SceneCollection collection = Create(_newCollectionName, setups);
            }
        }

        EditorGUILayout.Space();

        GUILayout.Box("Scene Collection assets are saved in Assets/SceneCollections. To load a Scene Collection, open the asset by double clicking it in the Project view, like you would a normal Scene.");
    }
示例#20
0
        void OnGUI()
        {
            // Make the window scrollable
            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GL_EXPAND_WIDTH, GL_EXPAND_HEIGHT);

            GUILayout.BeginVertical();

            GUILayout.Space(10);

            if (currentPhase == Phase.Processing)
            {
                GUILayout.Label(". . . something went wrong, check console . . .");
            }
            else if (currentPhase == Phase.Setup)
            {
                if (GUILayout.Button("GO!", GL_HEIGHT_30))
                {
                    initialSceneSetup = EditorSceneManager.GetSceneManagerSetup();

                    ExecuteQuery();
                }
            }
            else if (currentPhase == Phase.Complete)
            {
            }

            GUILayout.EndVertical();

            EditorGUILayout.EndScrollView();
        }
示例#21
0
        public static void InstallUpdate()
        {
            Requirement requirements = MeetsUnityRequirements();

            if (!requirements.success)
            {
                EditorUtility.DisplayDialog(REQUIREMENTS_TITLE, requirements.message, "Ok");
                return;
            }

            Debug.Log("Preparing installation...");
            if (!File.Exists(Path.Combine(Application.dataPath, PACKAGE_PATH)))
            {
                string path = Path.Combine(Application.dataPath, PACKAGE_PATH);
                Debug.LogError("Unable to locate Package file at: " + path);
                return;
            }

            if (!File.Exists(Path.Combine(Application.dataPath, CONFIG_PATH)))
            {
                string path = Path.Combine(Application.dataPath, CONFIG_PATH);
                Debug.LogError("Unable to locate Config file at: " + path);
                return;
            }

            EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();
            SceneSetup[] scenesSetup = EditorSceneManager.GetSceneManagerSetup();
            EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);

            string[] removeFolders = Config.GetUpdate().removeDirectories;
            for (int i = 0; i < removeFolders.Length; ++i)
            {
                string assetPath = Path.Combine(Application.dataPath, removeFolders[i]);
                if (File.Exists(assetPath) || Directory.Exists(assetPath))
                {
                    FileUtil.DeleteFileOrDirectory(assetPath);
                }
            }

            Debug.Log("Installing Game Creator...");
            AssetDatabase.ImportPackage(
                Path.Combine(ASSETS_PATH, PACKAGE_PATH),
                Config.GetUpdate().interactiveInstall
                );

            Debug.Log("<b>Installation Complete</b>!");
            if (scenesSetup != null && scenesSetup.Length > 0)
            {
                EditorSceneManager.RestoreSceneManagerSetup(scenesSetup);
            }

            EditorUtility.CopySerialized(Config.GetUpdate(), Config.GetCurrent());

            EditorUtility.DisplayDialog(
                MSG_COMPLETE1,
                string.Format(MSG_COMPLETE2, Config.GetUpdate().version),
                "Ok"
                );
        }
示例#22
0
        private static void luliFalse()
        {
            GraphicsSettings.lightsUseLinearIntensity = false;
            EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();
            var scn = EditorSceneManager.GetSceneManagerSetup();

            EditorSceneManager.OpenScene(scn[0].path);
        }
示例#23
0
 private static IEnumerable <Scene> GetOpenScenes()
 {
     string[] guids = EditorSceneManager.GetSceneManagerSetup().Select(scene => scene.path).ToArray();
     foreach (string guid in guids)
     {
         yield return(EditorSceneManager.OpenScene(guid));
     }
 }
示例#24
0
 static void OnRealSceneClosed(UnityEngine.SceneManagement.Scene scene)
 {
     // Check if scene was closed or just unloaded.
     if (EditorSceneManager.GetSceneManagerSetup().Where(x => x.path == scene.path).Count() == 0)
     {
         RefreshCurrentSceneDefinition();
     }
 }
        /// <summary>
        /// OnBeforeSerialize is called whenever we're about to save or inspect this Component.
        /// We want to match exactly what the Editor has in terms of Scene setup, so we do it here.
        /// </summary>
        public void OnBeforeSerialize()
        {
#if UNITY_EDITOR
            if (!this || BuildPipeline.isBuildingPlayer || Application.isPlaying)
            {
                return;
            }

            // Save off the scene path
            if (gameObject && gameObject.scene.IsValid())
            {
                _thisScenePath = gameObject.scene.path;
            }

            // We don't care about the scene setup
            if (!_isMainScene)
            {
                return;
            }

            var newSceneSetup = new List <SceneEntry>();
            var activeScene   = EditorSceneManager.GetActiveScene();

            // Update our scene setup
            SceneSetup[] editorSceneSetup = EditorSceneManager.GetSceneManagerSetup();
            for (int i = 0; i < editorSceneSetup.Length; ++i)
            {
                // If we're the active scene, don't save it.
                var editorEntry = editorSceneSetup[i];
                if (editorEntry.path == activeScene.path)
                {
                    continue;
                }

                var newEntry = new SceneEntry(editorEntry);
                newSceneSetup.Add(newEntry);

                // Save the baked settings
                var oldEntry = _sceneSetup.Find(x => newEntry.scene.Equals(x.scene));
                if (oldEntry != null)
                {
                    newEntry.loadMethod = oldEntry.loadMethod;
                }
            }

            // If we had a new scene setup...
            if (!newSceneSetup.SequenceEqual(_sceneSetup))
            {
                _sceneSetup = newSceneSetup;
                EditorUtility.SetDirty(this);

                if (gameObject)
                {
                    EditorSceneManager.MarkSceneDirty(gameObject.scene);
                }
            }
#endif
        }
示例#26
0
        public static void BakeMultipleScenes(string[] paths)
        {
            if (paths.Length == 0)
            {
                return;
            }

            for (int i = 0; i < paths.Length; i++)
            {
                for (int j = i + 1; j < paths.Length; j++)
                {
                    if (paths[i] == paths[j])
                    {
                        throw new System.Exception("no duplication of scenes is allowed");
                    }
                }
            }

            if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
            {
                return;
            }

            var sceneSetup = EditorSceneManager.GetSceneManagerSetup();

            // Restore old scene setup once the bake finishes
            Action OnBakeFinish = null;

            OnBakeFinish = () =>
            {
                EditorSceneManager.SaveOpenScenes();
                if (sceneSetup.Length > 0)
                {
                    EditorSceneManager.RestoreSceneManagerSetup(sceneSetup);
                }
                Lightmapping.bakeCompleted -= OnBakeFinish;
            };

            // Call BakeAsync when all scenes are loaded and attach cleanup delegate
            EditorSceneManager.SceneOpenedCallback BakeOnAllOpen = null;
            BakeOnAllOpen = (UnityEngine.SceneManagement.Scene scene, SceneManagement.OpenSceneMode loadSceneMode) =>
            {
                if (EditorSceneManager.loadedSceneCount == paths.Length)
                {
                    BakeAsync();
                    Lightmapping.bakeCompleted     += OnBakeFinish;
                    EditorSceneManager.sceneOpened -= BakeOnAllOpen;
                }
            };

            EditorSceneManager.sceneOpened += BakeOnAllOpen;

            EditorSceneManager.OpenScene(paths[0]);
            for (int i = 1; i < paths.Length; i++)
            {
                EditorSceneManager.OpenScene(paths[i], OpenSceneMode.Additive);
            }
        }
示例#27
0
        private void OnGUI()
        {
            GUILayout.BeginVertical();
            {
                GUILayout.Label("Loaded scenes");

                if (!Application.isPlaying)
                {
                    SceneListScrollViewPosition = GUILayout.BeginScrollView(SceneListScrollViewPosition);
                    {
                        SceneSetup[] sceneSetups = EditorSceneManager.GetSceneManagerSetup();
                        for (int i = 0; i < sceneSetups.Length; ++i)
                        {
                            GUILayout.BeginHorizontal();
                            {
                                GUILayout.Space(20);
                                GUILayout.Label(sceneSetups[i].path);
                            }
                            GUILayout.EndHorizontal();
                        }
                    }
                    GUILayout.EndScrollView();
                }
                else
                {
                    GUILayout.Label("Not available during Play");
                }
            }
            GUILayout.EndVertical();

            GUILayout.Space(5);

            GUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Save scenes"))
                {
                    PSSceneManagerUtility.SaveSceneAsset();
                    Status = "Scenes saved !";
                }

                if (GUILayout.Button("Restore scenes"))
                {
                    if (PSSceneManagerUtility.LoadSceneAsset())
                    {
                        Status = "Load success ! ";
                    }
                    else
                    {
                        Status = "Cannot load asset : " + PSSceneManagerUtility.DetectSaveDatas();
                    }
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(5);

            GUILayout.Label(Status);
        }
        public BuildStateCleanup(bool sceneBackupAndRestore, string tempBuildPath)
        {
            m_SceneBackup = sceneBackupAndRestore;
            if (m_SceneBackup)
                m_Scenes = EditorSceneManager.GetSceneManagerSetup();

            m_TempPath = tempBuildPath;
            Directory.CreateDirectory(m_TempPath);
        }
示例#29
0
        internal void SwitchToEditMode()
        {
            m_EditMode = EditMode.Starting;

            // Lock inspector
            ChangeInspectorLock(true);

            // Store current setup in hierarchy
            sceneSetup = EditorSceneManager.GetSceneManagerSetup();

            // Load temp scene
            Scene scene = EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);

            scene.name = "Avatar Configuration";

            // Instantiate character
            m_GameObject = Instantiate(prefab) as GameObject;
            if (serializedAssetImporter.FindProperty("m_OptimizeGameObjects").boolValue)
            {
                AnimatorUtility.DeoptimizeTransformHierarchy(m_GameObject);
            }

            // First get all available modelBones
            Dictionary <Transform, bool> modelBones = AvatarSetupTool.GetModelBones(m_GameObject.transform, true, null);

            AvatarSetupTool.BoneWrapper[] humanBones = AvatarSetupTool.GetHumanBones(serializedAssetImporter, modelBones);

            m_ModelBones = AvatarSetupTool.GetModelBones(m_GameObject.transform, false, humanBones);

            Selection.activeObject = m_GameObject;

            // Unfold all nodes in hierarchy
            // TODO@MECANIM: Only expand actual bones
            foreach (SceneHierarchyWindow shw in Resources.FindObjectsOfTypeAll(typeof(SceneHierarchyWindow)))
            {
                shw.SetExpandedRecursive(m_GameObject.GetInstanceID(), true);
            }
            CreateEditor();

            m_EditMode = EditMode.Editing;

            // Frame in scene view
            m_SceneStates = new List <SceneStateCache>();
            foreach (SceneView s in SceneView.sceneViews)
            {
                m_SceneStates.Add(new SceneStateCache {
                    state = new SceneView.SceneViewState(s.sceneViewState), view = s
                });
                s.sceneViewState.showFlares          = false;
                s.sceneViewState.showMaterialUpdate  = false;
                s.sceneViewState.showFog             = false;
                s.sceneViewState.showSkybox          = false;
                s.sceneViewState.showImageEffects    = false;
                s.sceneViewState.showParticleSystems = false;
                s.FrameSelected();
            }
        }
示例#30
0
 public SceneSubJob(SearchJob j, AssetScope sc, string[] allAssets, string[] s) : base(j, sc, allAssets, s, false)
 {
     sceneSetups = EditorSceneManager.GetSceneManagerSetup();
     foreach (SceneSetup sceneSetup in sceneSetups)
     {
         loadScenesHash[sceneSetup.path] = sceneSetup;
         // Debug.Log("[SceneSubJob] scene:"+sceneSetup.path);
     }
 }