Ejemplo n.º 1
0
 private void drawGameScenesTab()
 {
     if (!AllGameScriptableScenes.Instance)
     {
         EditorTools.drawMessage("AllGameScriptableScenes has not been created yet.", MessageType.Info);
         if (EditorTools.createListButton("Create AllScriptableScenes Object", false))
         {
             AllGameScriptableScenesEditor.CreateAllGameScriptableScenesAsset();
         }
     }
     else
     {
         Editor.CreateEditor(AllGameScriptableScenes.Instance).OnInspectorGUI();
     }
 }
    private void editorGUI(bool removeButton)
    {
        EditorGUILayout.BeginVertical(GUI.skin.box);

        GUILayout.BeginHorizontal(EditorStyles.inspectorDefaultMargins);

        scriptableScene.isExpanded = EditorGUILayout.Foldout(scriptableScene.isExpanded, new GUIContent(scriptableScene.name), true, EditorStyles.foldout);

        SceneAsset oldScene = AssetDatabase.LoadAssetAtPath <SceneAsset>(scriptableScene.scenePath);

        serializedObject.Update();

        // Display a button showing a '-' that if clicked removes this Condition from the AllConditions asset.
        if (removeButton && EditorTools.createListButton("-", true, GUILayout.Width(removeButtonWidth)))
        {
            AllGameScriptableScenesEditor.RemoveScriptableScene(scriptableScene);
            return;
        }

        GUILayout.EndHorizontal();

        if (scriptableScene.isExpanded)
        {
            EditorGUI.BeginChangeCheck();

            EditorGUI.indentLevel += 1;
            EditorGUILayout.LabelField("Unity Scene");
            EditorGUI.indentLevel -= 1;
            GUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins);

            SceneAsset newScene = EditorGUILayout.ObjectField(oldScene, typeof(SceneAsset), false) as SceneAsset;

            GUILayout.Space(5);

            EditorTools.createArrayPropertyButtons(sceneStartingPositionsNamesProperty, sceneStartingPositionsNamesPropName, GUILayout.Width(30f), true);

            if (sceneStartingPositionsNamesProperty.arraySize > 0)
            {
                for (int i = 0; i < sceneStartingPositionsNamesProperty.arraySize; i++)
                {
                    GUILayout.Space(5);
                    EditorGUILayout.BeginVertical(GUI.skin.box);
                    EditorGUILayout.PropertyField(sceneStartingPositionsNamesProperty.GetArrayElementAtIndex(i), new GUIContent("Position Name " + i), true);
                    EditorGUILayout.EndVertical();
                }
            }

            GUILayout.EndVertical();

            if (newScene)
            {
                scriptableScene.name = newScene.name;
            }


            if (EditorGUI.EndChangeCheck() && newScene != null)
            {
                string newPath = AssetDatabase.GetAssetPath(newScene.GetInstanceID());
                scenePathProperty.stringValue = newPath;
                AssetDatabase.SaveAssets();
            }
        }

        EditorGUILayout.EndVertical();

        // Push the values from the serializedObject back to the target.
        serializedObject.ApplyModifiedProperties();
    }