Пример #1
0
        void OnEnable()
        {
            transitionScene     = serializedObject.FindProperty("transitionScene");
            transitionScenePath = serializedObject.FindProperty("transitionScenePath");

            loadEndNote = serializedObject.FindProperty("loadEndNote");

            if (transitionScenePath.stringValue != "")
            {
                InspectorTools.AddSceneToBuild(new EditorBuildSettingsScene(transitionScenePath.stringValue, true), -1);
            }
        }
        void CheckOrAddScenes()
        {
            Menu menu = (Menu)menuType.enumValueIndex;

            if (menu == Menu.Main)
            {
                SerializedProperty levelsArr = levels.FindPropertyRelative("levels");
                for (int i = 0; i < levelsArr.arraySize; i++)
                {
                    SerializedProperty levelPath = levelsArr.GetArrayElementAtIndex(i).FindPropertyRelative("scenePath");
                    InspectorTools.AddSceneToBuild(new EditorBuildSettingsScene(levelPath.stringValue, true));
                }
            }
            else
            {
                SerializedProperty mainMenuLevelPath = mainMenuLevel.FindPropertyRelative("scenePath");
                InspectorTools.AddSceneToBuild(new EditorBuildSettingsScene(mainMenuLevelPath.stringValue, true), 0);
            }
        }
        public void DrawGameLevel(SerializedProperty level, string label, uint spaceCount = 0, bool arrayMem = false, int currentIndex = 0)
        {
            EditorGUILayout.BeginHorizontal();

            level.isExpanded = EditorGUILayout.Foldout(level.isExpanded, label);

            InspectorTools.Space(2);

            if (arrayMem)
            {
                if (levelIndex == currentIndex)
                {
                    if (GUILayout.Button("Deselect"))
                    {
                        levelIndex = -1;
                    }
                }
                else if (GUILayout.Button("Select"))
                {
                    levelIndex = currentIndex;
                }
            }

            EditorGUILayout.EndHorizontal();

            if (arrayMem)
            {
                InspectorTools.Space();
            }

            if (level.isExpanded)
            {
                EditorGUI.indentLevel++;
                SerializedProperty name = level.FindPropertyRelative("name");

                SerializedProperty sceneName = level.FindPropertyRelative("sceneName");
                SerializedProperty scenePath = level.FindPropertyRelative("scenePath");

                SerializedProperty image = level.FindPropertyRelative("image");

                SerializedProperty description = level.FindPropertyRelative("description");

                if (scenePath.stringValue == "" || sceneName.stringValue == "")
                {
                    sceneName.stringValue = "";
                    scenePath.stringValue = "";
                }

                SceneAsset scene = AssetDatabase.LoadAssetAtPath <SceneAsset>(scenePath.stringValue);

                EditorGUI.BeginChangeCheck();

                scene = (SceneAsset)EditorGUILayout.ObjectField("Scene", scene, typeof(SceneAsset), false);

                if (EditorGUI.EndChangeCheck())
                {
                    if (scene)
                    {
                        scenePath.stringValue = AssetDatabase.GetAssetPath(scene);
                        sceneName.stringValue = scene.name;

                        InspectorTools.AddSceneToBuild(new EditorBuildSettingsScene(scenePath.stringValue, true), 0);
                    }
                    else
                    {
                        sceneName.stringValue = "";
                        scenePath.stringValue = "";
                    }
                }

                EditorGUILayout.PropertyField(image, new GUIContent("Preview"));

                name.stringValue = EditorGUILayout.TextField("Name", name.stringValue);

                EditorGUILayout.BeginVertical();
                EditorGUILayout.LabelField("Description");
                description.stringValue = EditorGUILayout.TextArea(description.stringValue);
                EditorGUILayout.EndVertical();

                InspectorTools.Space(spaceCount);
                EditorGUI.indentLevel--;
            }
        }