Beispiel #1
0
    public static void StartEditWidget(GWidget widget)
    {
        EditorSceneManager.UnloadSceneAsync(EditorSceneManager.GetActiveScene());
        EditorSceneManager.NewSceneCreatedCallback fun = (UnityEngine.SceneManagement.Scene scene, NewSceneSetup setup, NewSceneMode mode) => {
            EditorSceneManager.SetActiveScene(scene);
            //创建canvas
            GameObject canvasObj = new GameObject("Canvas");
            Canvas     canvas    = canvasObj.AddComponent <Canvas>();
            canvas.renderMode = RenderMode.ScreenSpaceOverlay;
            new GameObject("EventSystem").AddComponent <UnityEngine.EventSystems.EventSystem>();

            //遮挡背景
            //GameObject bkgObj = new GameObject("background");
            //bkgObj.transform.SetParent(canvas.transform,false);
            //Image image = bkgObj.AddComponent<Image>();
            //image.rectTransform.sizeDelta = Vector2.zero;
            //image.rectTransform.anchorMin = Vector2.zero;
            //image.rectTransform.anchorMax = Vector2.one;
            //image.rectTransform.anchoredPosition = Vector2.zero;
            //image.color = Color.black;

            //将要编辑的组件放进来
            GameObject obj = (GameObject)PrefabUtility.InstantiatePrefab(widget.gameObject, scene);
            obj.transform.SetParent(canvasObj.transform, false);
            obj.SetActive(true);
            Selection.activeObject = obj;
        };
        EditorSceneManager.newSceneCreated += fun;
        EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Additive);
        EditorSceneManager.newSceneCreated -= fun;
    }
        public static void CloseAndAskSaveIfUserWantsTo(SubScene[] subScenes)
        {
            if (!Application.isPlaying)
            {
                var dirtyScenes = new List <Scene>();
                foreach (var scene in subScenes)
                {
                    if (scene.LoadedScene.isLoaded && scene.LoadedScene.isDirty)
                    {
                        dirtyScenes.Add(scene.LoadedScene);
                    }
                }

                if (dirtyScenes.Count != 0)
                {
                    if (!EditorSceneManager.SaveModifiedScenesIfUserWantsTo(dirtyScenes.ToArray()))
                    {
                        return;
                    }
                }

                CloseSceneWithoutSaving(subScenes);
            }
            else
            {
                foreach (var scene in subScenes)
                {
                    if (scene.LoadedScene.isLoaded)
                    {
                        EditorSceneManager.UnloadSceneAsync(scene.LoadedScene);
                    }
                }
            }
        }
Beispiel #3
0
 private void ClearParticleFactoryScene(PlayModeStateChange obj)
 {
     if (poolScene.IsValid())
     {
         EditorSceneManager.UnloadSceneAsync(poolScene);
     }
 }
    static void End()
    {
        var scene = EditorSceneManager.GetSceneByName(string.Empty);

        if (scene.isLoaded)
        {
            var audioSource = FindAudioSource(scene);

            if (audioSource != null)
            {
                if (scene.rootCount == 1)
                {
                    EditorSceneManager.UnloadSceneAsync(scene);
                }
                else
                {
                    GameObject.DestroyImmediate(audioSource.gameObject);
                }
            }

            targetTime = 0f;

            EditorApplication.update -= Update;
        }
    }
        private void CheckAndAddGotoNextSceneBehavior(string[] levels)
        {
            for (int i = 0; i < levels.Length; ++i)
            {
                string       levelPath      = levels[i];
                var          scene          = EditorSceneManager.OpenScene(levelPath);
                GameObject[] objects        = scene.GetRootGameObjects();
                bool         componentFound = false;

                foreach (GameObject go in objects)
                {
                    GotoNextScene component = go.GetComponent <GotoNextScene>();
                    if (component != null)
                    {
                        component.m_NextSceneIndex = (i + 1) % levels.Length;
                        componentFound             = true;
                        break;
                    }
                }

                if (!componentFound)
                {
                    GameObject    gotoNextScene = new GameObject("GotoNextScene");
                    GotoNextScene component     = gotoNextScene.AddComponent <GotoNextScene>();
                    component.m_NextSceneIndex = (i + 1) % levels.Length;
                }

                EditorSceneManager.SaveScene(scene);
                EditorSceneManager.UnloadSceneAsync(scene);
            }
        }
Beispiel #6
0
        public void UnloadOtherScenes(string [] ignoreScenes)
        {
#if UNITY_EDITOR
            int numScenes = EditorSceneManager.loadedSceneCount;
#else
            int numScenes = SceneManager.sceneCount;
#endif
            for (int i = 0; i < numScenes; i++)
            {
                Scene scene;
#if UNITY_EDITOR
                scene = EditorSceneManager.GetSceneAt(i);
#else
                scene = SceneManager.GetSceneAt(i);
#endif
                if (System.Array.Exists <string>(ignoreScenes, (x) => x.Equals(scene.path)))
                {
                    continue;
                }
#if UNITY_EDITOR
                mCurrentUnloadOps.Add(EditorSceneManager.UnloadSceneAsync(scene));
#else
                mCurrentUnloadOps.Add(SceneManager.UnloadSceneAsync(scene));
#endif
            }
        }
Beispiel #7
0
        public void Create(Map map, Area area = null, ulong areaId = 0)
        {
            m_Map = map;
            if (area != null)
            {
                m_Area     = area;
                m_AABB     = m_Area.GetAABB();
                VoxelGrid  = m_Area.VoxelGrid;
                m_Diameter = m_Area.GetDiameter();
            }
            else
            {
                GameObject areaObj = new GameObject(string.Format("Area_{0}", areaId));
                m_Area     = areaObj.AddComponent <Area>();
                m_Area.Uid = areaId;
            }
            m_AreaUid       = m_Area.Uid;
            m_AreaScenePath = string.Format("{0}/Area_{1}_{2}.unity", m_Map.GetOwnerAreaPath(), m_Map.Uid, m_AreaUid);
            gameObject.name = string.Format("AreaSpawner_{0}_{1}", m_Map.Uid, m_AreaUid);
            Scene scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Additive);

            if (scene != null)
            {
                SceneManager.MoveGameObjectToScene(m_Area.gameObject, scene);
                SceneManager.SetActiveScene(scene);
                EditorSceneManager.SaveScene(scene, m_AreaScenePath);
                EditorSceneManager.UnloadSceneAsync(scene);
            }
            EditorSceneManager.CloseScene(scene, true);
        }
Beispiel #8
0
        private void LoadAllScenes(BiomeType biome)
        {
            var scenes = AssetDatabase.FindAssets("t:Scene", new[] { "Assets/Scenes/Maps/" + biome.Name });

            for (int i = 0; i < EditorSceneManager.sceneCount; i++)
            {
                if (EditorSceneManager.GetSceneAt(i).name != "MapSetup" && !EditorSceneManager.GetSceneAt(i).name.Contains(biome.Name))
                {
                    EditorSceneManager.UnloadSceneAsync(EditorSceneManager.GetSceneAt(i),
                                                        UnloadSceneOptions.UnloadAllEmbeddedSceneObjects);
                }
            }

            foreach (var scene in scenes)
            {
                EditorSceneManager.OpenScene(AssetDatabase.GUIDToAssetPath(scene), OpenSceneMode.Additive);
            }

            if (EditorSceneManager.GetActiveScene().name != "MapSetup" && !EditorSceneManager.GetActiveScene().name.Contains(biome.Name))
            {
                EditorSceneManager.UnloadSceneAsync(EditorSceneManager.GetActiveScene(),
                                                    UnloadSceneOptions.UnloadAllEmbeddedSceneObjects);
            }

            if (!EditorSceneManager.GetSceneByName("MapSetup").IsValid())
            {
                EditorSceneManager.OpenScene("Assets/Scenes/GamplaySetup/MapSetup.unity", OpenSceneMode.Additive);
            }
        }
Beispiel #9
0
        public IEnumerator RecycleScene(string sceneName)
        {
#if UNITY_EDITOR
            yield return(EditorSceneManager.UnloadSceneAsync(sceneName, UnloadSceneOptions.UnloadAllEmbeddedSceneObjects));
#else
            yield return(break);
#endif
        }
Beispiel #10
0
 private void OnDisable()
 {
     UnregisterCallback <MouseDownEvent>(OnMouseDown);
     if (_tempScene != null && _tempScene.IsValid())
     {
         EditorSceneManager.UnloadSceneAsync(_tempScene);
     }
 }
Beispiel #11
0
        public void UnloadScene(string scene)
        {
#if UNITY_EDITOR
            mCurrentUnloadOps.Add(EditorSceneManager.UnloadSceneAsync(scene));
#else
            mCurrentUnloadOps.Add(SceneManager.UnloadSceneAsync(scene));
#endif
        }
Beispiel #12
0
        public bool InitializeMerge()
        {
            var activeScene = EditorSceneManager.GetActiveScene();

            if (activeScene.isDirty)
            {
                window.ShowNotification(new GUIContent("Please make sure there are no unsaved changes before attempting to merge."));
                return(false);
            }

            isMergingScene = true;
            var scenePath = activeScene.path;

            // Overwrite the current scene to prevent the reload/ignore dialog that pops up after the upcoming changes to the file.
            // Pressing "reload" on it would invalidate the GameObject references we're about to collect.
            EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);

            vcs.CheckoutOurs(scenePath);
            CheckoutTheirVersionOf(scenePath);
            AssetDatabase.Refresh();

            activeScene = EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Single);

            MergeAction.inMergePhase = false;
            ObjectDictionaries.Clear();

            List <GameObject> ourObjects;

            try
            {
                // Find all of "our" objects
                ourObjects = GetAllSceneObjects();
                ObjectDictionaries.AddToOurObjects(ourObjects);

                // Add "their" objects
                theirScene = EditorSceneManager.OpenScene(theirFilename, OpenSceneMode.Additive);

                var addedObjects = GetAllNewSceneObjects(ourObjects);
                ObjectDictionaries.AddToTheirObjects(addedObjects);
                BuildAllMergeActions(ourObjects, addedObjects);

                MoveGameObjectsToScene(theirScene.GetRootGameObjects(), activeScene);
            }
            finally
            {
                EditorSceneManager.UnloadSceneAsync(theirScene);
                AssetDatabase.DeleteAsset(theirFilename);
            }

            if (allMergeActions.Count == 0)
            {
                window.ShowNotification(new GUIContent("No conflict found for this scene."));
                return(false);
            }

            MergeAction.inMergePhase = true;
            return(true);
        }
Beispiel #13
0
    public static RenderTexture Render(GameObject gameObject, int resolution)
    {
        if (threePointLight == null)
        {
            threePointLight = Resources.Load <GameObject>("Prefabs/ThreePointLights");
        }

        //calculate object bounds
        Bounds bounds = new Bounds();

        foreach (MeshRenderer renderer in gameObject.GetComponentsInChildren <MeshRenderer>())
        {
            bounds.Encapsulate(renderer.bounds);
        }

        var renderScene = EditorSceneManager.NewPreviewScene();

        GameObject parent = new GameObject("Scene Parent");

        GameObject instance = GameObjectFactory.Instantiate(gameObject, parent: parent.transform);

        GameObject cameraGameObject = GameObjectFactory.Create("Camera", parent: parent.transform);

        var camera = cameraGameObject.AddComponent <Camera>();

        camera.clearFlags             = CameraClearFlags.Nothing;
        camera.forceIntoRenderTexture = true;

        cameraGameObject.transform.position  = bounds.center + Vector3.right + Vector3.forward + Vector3.up;
        cameraGameObject.transform.position *= Mathf.Max(bounds.extents.x, bounds.extents.y, bounds.extents.z) * 1.2f;
        cameraGameObject.transform.rotation  = Quaternion.Euler(0, 225, 0) * Quaternion.Euler(45f, 0, 0);

        RenderTexture texture = new RenderTexture(resolution, resolution, 16);

        texture.Create();

        camera.targetTexture = texture;
        camera.scene         = renderScene;

        GameObject lightGameObject = GameObjectFactory.Instantiate(threePointLight, parent: parent.transform);
        var        light           = lightGameObject.AddComponent <Light>();

        light.type = LightType.Directional;
        light.transform.rotation = Quaternion.Euler(50f, -30f, 0f);

        EditorSceneManager.MoveGameObjectToScene(parent, renderScene);

        camera.Render();
        camera.targetTexture = null;

        GameObject.DestroyImmediate(parent);

        EditorSceneManager.UnloadSceneAsync(renderScene);

        return(texture);
    }
Beispiel #14
0
        private void RemovePoints(ParticleManager gm)
        {
            if (poolScene.IsValid())
            {
                gm.system.Clear();
                EditorSceneManager.UnloadSceneAsync(poolScene);

                builtPoints = false;
            }
        }
        protected void ResetTest()
        {
            if (loadedResource != null)
            {
                UnityEngine.Object.Destroy(loadedResource);
            }

            if (loadedSceneName != null)
            {
                EditorSceneManager.UnloadSceneAsync(SceneManager.GetSceneByName(loadedSceneName));
                loadedSceneName = null;
            }

            ResetTimeScale();
        }
Beispiel #16
0
        public void ConvertGameObject_HasOnlyTransform_ProducesEntityWithPositionAndRotation([Values] bool useDiffing)
        {
            // Prepare scene
            var scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene);

            SceneManager.SetActiveScene(scene);

            var go = new GameObject("Test Conversion");

            go.transform.localPosition = new Vector3(1, 2, 3);

            // Convert
            if (useDiffing)
            {
                var shadowWorld = new World("Shadow");
                ConvertSceneAndApplyDiff(scene, shadowWorld, m_Manager.World);
                shadowWorld.Dispose();
            }
            else
            {
                ConvertScene(scene, default(Unity.Entities.Hash128), m_Manager.World);
            }

            // Check
            var entities = m_Manager.GetAllEntities();

            Assert.AreEqual(1, entities.Length);
            var entity = entities[0];

            Assert.AreEqual(useDiffing ? 4 : 3, m_Manager.GetComponentCount(entity));
            Assert.IsTrue(m_Manager.HasComponent <Translation>(entity));
            Assert.IsTrue(m_Manager.HasComponent <Rotation>(entity));
            if (useDiffing)
            {
                Assert.IsTrue(m_Manager.HasComponent <EntityGuid>(entity));
            }

            Assert.AreEqual(new float3(1, 2, 3), m_Manager.GetComponentData <Translation>(entity).Value);
            Assert.AreEqual(quaternion.identity, m_Manager.GetComponentData <Rotation>(entity).Value);
            var localToWorld = m_Manager.GetComponentData <LocalToWorld>(entity).Value;

            Assert.IsTrue(localToWorld.Equals(go.transform.localToWorldMatrix));

            // Unload
            EditorSceneManager.UnloadSceneAsync(scene);
        }
Beispiel #17
0
        //@TODO: Move this into SceneManager
        void UnloadScene()
        {
    #if UNITY_EDITOR
            var scene = LoadedScene;
            if (scene.IsValid())
            {
                // If there is only one scene left in the editor, we create a new empty scene
                // before unloading this sub scene
                if (EditorSceneManager.loadedSceneCount == 1)
                {
                    Debug.Log("Creating new scene");
                    EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Additive);
                }

                EditorSceneManager.UnloadSceneAsync(scene);
            }
    #endif
        }
    static void DoCleanup()
    {
        var sceneGUIDs = AssetDatabase.FindAssets("t:Scene");

        string[] scenePaths = sceneGUIDs.Select(i => AssetDatabase.GUIDToAssetPath(i)).ToArray();

        for (int i = 0; i < scenePaths.Length; i++)
        {
            var scene = EditorSceneManager.OpenScene(scenePaths[i], OpenSceneMode.Additive);

            EditorSceneManager.MarkSceneDirty(scene);
            EditorSceneManager.SaveScene(scene);

            if (scene != EditorSceneManager.GetActiveScene())
            {
                EditorSceneManager.UnloadSceneAsync(scene);
            }
        }
    }
Beispiel #19
0
        public static void EnterPreviewMode(GameObject clone)
        {
            Scene originalScene = EditorSceneManager.GetActiveScene();

            originalScenePath = EditorApplication.currentScene;

            Scene previewScene = EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Additive);

            EditorSceneManager.MoveGameObjectToScene(clone, previewScene);

            EditorSceneManager.UnloadSceneAsync(originalScene);
            previewModeEnable  = true;
            inspectedGrabbable = GameObject.FindObjectOfType <VR_Grabbable>();
            activeController   = GameObject.FindObjectOfType <VR_Controller>();

            OverrideGrabAnimation();

            activeController.Animator.SetBool("IsGrabbing", true);

            EditorApplication.update += Update;
        }
        public IEnumerator TearDown()
        {
            ScriptableObject.Destroy(settingController);

            yield return(EditorSceneManager.UnloadSceneAsync(TEST_SCENE_NAME));
        }
Beispiel #21
0
        protected void UnloadScene(string sceneName)
        {
            var scene = EditorSceneManager.GetSceneByName(sceneName);

            EditorSceneManager.UnloadSceneAsync(scene);
        }
        public static void OnHierarchyGUI(int instanceId, Rect selectionRect)
        {
            // if(buttonStyle == null)
            {
                buttonStyle         = new GUIStyle(GUI.skin.label);
                buttonStyle.padding = new RectOffset();
                buttonStyle.border  = new RectOffset();
            }
            buttonDim = EditorGUIUtility.singleLineHeight - 2;
            Event e   = Event.current;
            var   obj = EditorUtility.InstanceIDToObject(instanceId);

            // if obj is null, then the item is a Scene (the header for each loaded scene)
            if (obj)
            {
                GameObject g          = obj as GameObject;
                Rect       buttonRect = new Rect(selectionRect);
                buttonRect.x       = buttonRect.xMax - buttonDim;
                buttonRect.width   = buttonDim;
                buttonRect.height -= 2;
                buttonRect.y      += 1;

                GUI.DrawTexture(buttonRect, g.activeSelf
                    ? AssetDatabase.LoadAssetAtPath <Texture2D>(packagePath + "Icons/IconEnabled.png")
                    : AssetDatabase.LoadAssetAtPath <Texture2D>(packagePath + "Icons/IconDisabled.png"));

                if (e.isMouse && e.type == EventType.MouseDown && buttonRect.Contains(e.mousePosition))
                {
                    switch (e.button)
                    {
                    case 0:
                        string prefix = g.activeSelf ? "Dis" : "En";
                        Undo.RecordObject(g, $"{prefix}able {g.name}");
                        g.SetActive(!g.activeSelf);
                        EditorUtility.SetDirty(g);
                        break;

                    case 1:
                        GenericMenu menu = new GenericMenu();
                        menu.AddItem(new GUIContent("Show Component Icons", ""), EditorPrefs.GetBool(showComponentIconsKey, true), () =>
                        {
                            EditorPrefs.SetBool(showComponentIconsKey, !EditorPrefs.GetBool(showComponentIconsKey, true));
                        });
                        menu.AddItem(new GUIContent("Show Indent Rainbow", ""), EditorPrefs.GetBool(showIndentRainbowKey, true), () =>
                        {
                            EditorPrefs.SetBool(showIndentRainbowKey, !EditorPrefs.GetBool(showIndentRainbowKey, true));
                        });
                        menu.ShowAsContext();
                        break;
                    }
                    e.Use();
                }
                if (!EditorPrefs.GetBool(showComponentIconsKey, true))
                {
                    return;
                }
                buttonRect.x    -= 3;
                buttonRect.width = 1;
                GUI.color        = Color.black * 0.5f;
                GUI.DrawTexture(buttonRect, EditorGUIUtility.whiteTexture);
                GUI.color        = Color.white;
                buttonRect.x    -= 3;
                buttonRect.width = buttonDim;
                Component[] components = g.GetComponents <Component>();
                foreach (var component in components)
                {
                    if (component == null || component.GetType() == typeof(Transform))
                    {
                        continue;
                    }
                    buttonRect.x -= buttonDim + padding;
                    GUI.color     = new Color(1, 1, 1, 0.5f);
                    GUI.Box(buttonRect, "");
                    GUI.color = Color.white;
                    Type type = component.GetType();
                    GUI.Label(buttonRect, new GUIContent(EditorGUIUtility.ObjectContent(component, type).image, type.ToString()), buttonStyle);
                    var b = component as Behaviour;
                    if (b)
                    {
                        if (!b.enabled)
                        {
                            GUI.DrawTexture(new RectOffset(-(int)(buttonDim * 0.4f), 0, -(int)(buttonDim * 0.4f), 0).Add(buttonRect), AssetDatabase.LoadAssetAtPath <Texture2D>(packagePath + "Icons/IconRemove.png"));
                            EditorGUI.DrawRect(buttonRect, new Color(1, 0, 0, 0.25f));
                        }
                    }
                    else
                    {
                        Type t = component.GetType();
                        if (t.GetMember("get_enabled", BindingFlags.Public | BindingFlags.Instance).Length > 0)
                        {
                            if (!(bool)t.InvokeMember("get_enabled", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, component, null))
                            {
                                GUI.DrawTexture(new RectOffset(-(int)(buttonDim * 0.4f), 0, -(int)(buttonDim * 0.4f), 0).Add(buttonRect), AssetDatabase.LoadAssetAtPath <Texture2D>(packagePath + "Icons/IconRemove.png"));
                                EditorGUI.DrawRect(buttonRect, new Color(1, 0, 0, 0.25f));
                            }
                        }
                    }
                }
                if (!g.activeInHierarchy)
                {
                    GUI.color = new Color(1, 0, 0, 1f);
                    GUI.Box(selectionRect, "");
                    GUI.color = Color.white;
                }
                if (!EditorPrefs.GetBool(showIndentRainbowKey))
                {
                    return;
                }
                float   opacity    = 0.25f;
                float   luminosity = 0.666f;
                Color[] colors     = new Color[] { new Color(luminosity * 1.5f, 0, luminosity / 3, opacity), new Color(luminosity, luminosity * 2 / 3, 0, opacity), new Color(luminosity / 4, luminosity, 0, opacity), new Color(0, luminosity, luminosity, opacity), new Color(0, luminosity / 2, luminosity * 1.5f, opacity), new Color(luminosity, 0, luminosity * 1.5f, opacity) };
                int     pos        = (int)(selectionRect.xMin - 2) / 14 - 2;
                for (int i = 0; i <= pos; i++)
                {
                    GUI.color = colors[(i) % colors.Length];
                    // EditorGUI.DrawRect(new Rect(1 + (i + 1) * 14 + (14 - width), selectionRect.yMin, width, selectionRect.height), colors[(i) % colors.Length] / opacity);
                    GUI.DrawTexture(new Rect(1 + (i + 1) * 14, selectionRect.yMin, 14, selectionRect.height), AssetDatabase.LoadAssetAtPath <Texture>(packagePath + "Icons/IconGradient.psd"));
                    GUI.color = Color.white;
                }
                return;
            }
            Scene scene = GetSceneFromInstanceID(instanceId);

            buttonStyle         = new GUIStyle(GUI.skin.button);
            buttonStyle.padding = new RectOffset();
            selectionRect.x     = selectionRect.xMax - 35;
            selectionRect.width = buttonDim;
            using (new EditorGUI.DisabledScope(EditorSceneManager.sceneCount <= 1))
            {
                if (GUI.Button(selectionRect, new GUIContent(AssetDatabase.LoadAssetAtPath <Texture2D>(packagePath + "Icons/IconRemove.png"), "Remove scene"), buttonStyle))
                {
                    GenericMenu menu = new GenericMenu();
                    menu.AddItem(new GUIContent("Remove Scene"), false, () =>
                    {
                        if (scene.isDirty)
                        {
                            if (EditorUtility.DisplayDialog("Save modified scene?", string.Format("{0} has been modified. Save before removing scene?", scene.name), "Save", "Don't Save"))
                            {
                                EditorSceneManager.SaveScene(scene);
                            }
                        }
                        EditorSceneManager.UnloadSceneAsync(scene);
                    });
                    menu.ShowAsContext();
                }
                if (EditorSceneManager.sceneCount <= 1)
                {
                    GUI.color = disabledColor;
                    GUI.DrawTexture(selectionRect, EditorGUIUtility.whiteTexture);
                    GUI.color = Color.white;
                }
                selectionRect.x -= buttonDim + padding * 4;
            }
            using (new EditorGUI.DisabledScope(scene.isLoaded && EditorSceneManager.loadedSceneCount == 1))
            {
                if (GUI.Button(selectionRect, scene.isLoaded ? new GUIContent(AssetDatabase.LoadAssetAtPath <Texture2D>(packagePath + "Icons/IconEnabled.png"), "Unload Scene") : new GUIContent(AssetDatabase.LoadAssetAtPath <Texture2D>(packagePath + "Icons/IconDisabled.png"), "Load Scene"), buttonStyle))
                {
                    if (scene.isLoaded)
                    {
                        if (scene.isDirty)
                        {
                            if (EditorUtility.DisplayDialog("Save modified scene?", string.Format("{0} has been modified. Save before unloading scene?", scene.name), "Save", "Don't Save"))
                            {
                                EditorSceneManager.SaveScene(scene);
                            }
                        }
                        EditorSceneManager.CloseScene(scene, false);
                    }
                    else
                    {
                        EditorSceneManager.OpenScene(scene.path, OpenSceneMode.Additive);
                        SceneView.RepaintAll();
                    }
                }
                if (scene.isLoaded && EditorSceneManager.loadedSceneCount == 1)
                {
                    GUI.color = disabledColor;
                    GUI.DrawTexture(selectionRect, EditorGUIUtility.whiteTexture);
                    GUI.color = Color.white;
                }
            }
            // selectionRect.x -= buttonDim + padding;
            // using (new EditorGUI.DisabledScope(!scene.isLoaded))
            // {
            //     if (GUI.Button(selectionRect, new GUIContent("R", "Select root GameObjects in scene"), buttonStyle))
            //     {
            //         Selection.objects = scene.GetRootGameObjects();
            //     }
            //     if (!scene.isLoaded)
            //     {
            //         GUI.color = disabledColor;
            //         GUI.DrawTexture(selectionRect, EditorGUIUtility.whiteTexture);
            //         GUI.color = Color.white;
            //     }
            // }
            selectionRect.x -= buttonDim + padding;
            using (new EditorGUI.DisabledScope(!scene.isDirty))
            {
                if (GUI.Button(selectionRect, new GUIContent(AssetDatabase.LoadAssetAtPath <Texture2D>(packagePath + "Icons/IconSave.png"), "Save this scene"), buttonStyle))
                {
                    EditorSceneManager.SaveScene(scene, scene.path);
                }
                if (!scene.isDirty)
                {
                    GUI.color = disabledColor;
                    GUI.DrawTexture(selectionRect, EditorGUIUtility.whiteTexture);
                    GUI.color = Color.white;
                }
            }
            if (!string.IsNullOrEmpty(scene.path))
            {
                selectionRect.x -= buttonDim + padding;
                if (GUI.Button(selectionRect, new GUIContent(AssetDatabase.LoadAssetAtPath <Texture2D>(packagePath + "Icons/IconFind.png"), "Locate Scene Asset"), buttonStyle))
                {
                    EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(scene.path));
                }
            }
        }