Exemple #1
0
        private void DrawElement(Rect rect, int index, bool isActive, bool isFocused)
        {
            rect.y += 2;

            const int toggleWidth = 17;

            Rect loadSceneRect   = new Rect(rect.x + rect.width - toggleWidth * 2, rect.y, toggleWidth, rect.height);
            Rect activeSceneRect = new Rect(rect.x + rect.width - toggleWidth, rect.y, toggleWidth, rect.height);
            Rect labelRect       = new Rect(rect.x, rect.y, rect.width - (toggleWidth * 2) - 5, EditorGUIUtility.singleLineHeight);

            MultiScene.SceneInfo info = list[index];
            EditorGUI.BeginChangeCheck();
            SceneAsset scene = (SceneAsset)EditorGUI.ObjectField(labelRect, info.asset, typeof(SceneAsset), false);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(target, "Change Scene");
                info.asset = scene;
                target.sceneAssets[index] = info;
            }

            bool active = info.asset == target.activeScene;

            GUI.enabled = !active;
            EditorGUI.BeginChangeCheck();
            bool loadScene = GUI.Toggle(loadSceneRect, info.loadScene, loadSceneContent);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(target, "Change Load Scene");
                info.loadScene            = loadScene;
                target.sceneAssets[index] = info;
            }
            GUI.enabled = true;

            EditorGUI.BeginChangeCheck();
            bool setActive = GUI.Toggle(activeSceneRect, active, activeSceneContent);

            if (!EditorGUI.EndChangeCheck())
            {
                return;
            }
            if (!setActive)
            {
                return;
            }

            Undo.RecordObject(target, "Change Active Scene");
            target.activeScene = info.asset;
        }