/// <summary>
    /// Displays the Weapon field with the color of the component referenced
    /// </summary>
    void DisplayWeaponField(SerializedProperty weaponProp, int index)
    {
        PlayerShipShooter tgtObject = (PlayerShipShooter)target;

        //Needed or out-of-bound when expanding the size of the array in the inspector
        if (index >= tgtObject.weapons.Length)
        {
            return;
        }

        int referencedComponentId = weaponProp.objectReferenceInstanceIDValue;

        if (referencedComponentId != 0)
        {
            int cIdx = WeaponInspector.GetComponentData(referencedComponentId).colorIndex;
            GUI.backgroundColor = CustomEditorUtils.Colors[cIdx];
        }

        //Display the header/title of that weapon using the 'type' field value
        string title = tgtObject.weapons[index] != null ? tgtObject.weapons[index].type.ToString() : "No weapon";

        EditorGUILayout.PropertyField(weaponProp, new GUIContent(title));

        GUI.backgroundColor = CustomEditorUtils.ResetColor();
    }
    void OnGUI()
    {
        GUISkin        skin = (GUISkin)AssetDatabase.LoadAssetAtPath(LEVEL_SELECT_SKIN_PATH, typeof(GUISkin));
        SceneDirectory dir  = (SceneDirectory)AssetDatabase.LoadAssetAtPath(SCENE_DIR_PATH, typeof(SceneDirectory));

        for (int itr = 0; itr < dir.Scenes.Count; itr++)
        {
            string levelText = dir.Scenes[itr].sceneName;

            CustomEditorUtils.HeaderStart(levelText);

            if (GUILayout.Button("Load " + levelText, skin.button))
            {
                EditorApplication.OpenScene(SCENE_PATH + levelText + SCENE_EXTENSION);
            }

            EditorGUILayout.LabelField("Details", skin.customStyles[0]);
            foreach (string feature in dir.Scenes[itr].features)
            {
                EditorGUILayout.LabelField(feature);
            }

            CustomEditorUtils.HeaderEnd();
        }
    }
    protected void DrawQuickButton()
    {
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(10);
        EditorGUILayout.BeginVertical();

        string newQuickButton = CustomEditorUtils.DrawHeaderButtons(m_FormatData.QuickSetResolutions.ToArray(), 10, m_FormatData.CurrentSelectedQuickSetResolution, 20);

        if (newQuickButton != m_FormatData.CurrentSelectedQuickSetResolution)
        {
            m_FormatData.CurrentSelectedQuickSetResolution = newQuickButton;
            m_FormatData.OnQuickButtonChanged();
        }
        GUILayout.Space(10);

        EditorGUILayout.BeginVertical(GUI.skin.box, new GUILayoutOption[0]);
        m_FormatData.TargetImporterData.Readable      = EditorGUILayout.ToggleLeft("Read/Write", m_FormatData.TargetImporterData.Readable, new GUILayoutOption[0]);
        m_FormatData.TargetImporterData.sRGBTexture   = EditorGUILayout.ToggleLeft("sRGBTexture", m_FormatData.TargetImporterData.sRGBTexture, new GUILayoutOption[0]);
        m_FormatData.TargetImporterData.MipmapEnabled = EditorGUILayout.ToggleLeft("Mipmap", m_FormatData.TargetImporterData.MipmapEnabled, new GUILayoutOption[0]);
        m_FormatData.TargetImporterData.aTranparency  = EditorGUILayout.ToggleLeft("a is Transparency", m_FormatData.TargetImporterData.aTranparency, new GUILayoutOption[0]);
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndVertical();

        GUILayout.Space(10);
        EditorGUILayout.EndHorizontal();
    }
    private void DrawRestrictedObjectSection(BoundaryChecker checker)
    {
        // Info about the object restricted by the path
        CustomEditorUtils.HeaderStart("Restricted Object");

        checker.RestrictedObject         = (GameObject)EditorGUILayout.ObjectField("Restricted Object", checker.RestrictedObject, typeof(GameObject), true);
        checker.MaximumCheckDistance     = EditorGUILayout.FloatField("Max Node Check Distance", checker.MaximumCheckDistance);
        checker.MaximumAllowableDistance = EditorGUILayout.FloatField("Max Distance From Path", checker.MaximumAllowableDistance);

        CustomEditorUtils.HeaderEnd();
    }
Exemplo n.º 5
0
    private void DisplayColoredComment()
    {
        SerializedProperty commentProp  = serializedObject.FindProperty("_comment");
        GUIStyle           commentStyle = new GUIStyle(GUI.skin.textArea)
        {
            fontSize = 10
        };

        GUI.backgroundColor         = CustomEditorUtils.Colors[GetComponentData(serializedObject.targetObject.GetInstanceID()).colorIndex];
        EditorGUIUtility.labelWidth = 1;
        commentProp.stringValue     = GUILayout.TextArea(commentProp.stringValue, commentStyle);
        EditorGUIUtility.labelWidth = 0;
        GUI.backgroundColor         = CustomEditorUtils.ResetColor();
    }
    private void DrawClearPathSection(BoundaryChecker checker)
    {
        CustomEditorUtils.HeaderStart("Clear Path");

        deletePathConfirm = EditorGUILayout.ToggleLeft("Delete ENTIRE Path?", deletePathConfirm);

        // If user checked the confirm delete checkbox...
        if (deletePathConfirm)
        {
            // If user pressed delete button...
            if (GUILayout.Button("DELETE?"))
            {
                checker.DeleteEntirePath();
                deletePathConfirm = false;
            }
        }

        CustomEditorUtils.HeaderEnd();
    }
    /// <summary>
    /// Displays each field of componentsToTrigger array with the color of the component referenced
    /// </summary>
    protected void DisplayOneComponentField(SerializedProperty compFieldProp, int index = -1)
    {
        int referencedComponentId = compFieldProp.objectReferenceInstanceIDValue;

        if (referencedComponentId != 0)
        {
            int cIdx = TriggerableObjectInspector.GetComponentData(referencedComponentId).colorIndex;
            GUI.backgroundColor = CustomEditorUtils.Colors[cIdx];
        }

        if (index > -1)
        {
            string str = "#" + index.ToString();
            EditorGUIUtility.labelWidth = 35;
            EditorGUILayout.PropertyField(compFieldProp, new GUIContent(str));
            EditorGUIUtility.labelWidth = 0;
        }
        else
        {
            EditorGUILayout.PropertyField(compFieldProp);
        }

        GUI.backgroundColor = CustomEditorUtils.ResetColor();
    }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        // Get BoundaryChecker object
        BoundaryChecker checker = (BoundaryChecker)target;

        DrawRestrictedObjectSection(checker);

        DrawClearPathSection(checker);

        // Path editor
        CustomEditorUtils.HeaderStart("Path Editor");

        // If no path exists...
        if (checker.MainPathNodeCount == 0)
        {
            DrawNewPathButton(checker);
        }
        else
        {
            DrawMainPathNodePopup(checker);

            EditorGUILayout.Separator();

            DrawCustomLocationControls(checker);

            EditorGUILayout.Separator();

            EditorGUILayout.BeginHorizontal();

            DrawCreateNewBeforeButton(checker);

            DrawCreateNewAfterButton(checker);

            DrawDeleteNodeButton(checker);

            EditorGUILayout.EndHorizontal();

            // Allows for the selection of a node in the inspector
            if (GUILayout.Button("Select Node"))
            {
                Selection.activeGameObject = checker.GetMainPathNode(selectedMainPathIndex);
            }

            EditorGUILayout.Separator();

            DrawForkOptions(checker);

            CustomEditorUtils.HeaderEnd();
        }

        // Debugging info
        checker.ShowEditorLines = EditorGUILayout.ToggleLeft("Show Debug Lines", checker.ShowEditorLines);

        if (checker.ShowEditorLines)
        {
            checker.MainPathLineColor = EditorGUILayout.ColorField("Main Path Color", checker.MainPathLineColor);
            checker.ForkPathLineColor = EditorGUILayout.ColorField("Fork Path Color", checker.ForkPathLineColor);
        }
    }
    void OnGUI()
    {
        SceneDirectory dir = (SceneDirectory)AssetDatabase.LoadAssetAtPath(DIRECTORY_PATH + "/SceneDir.asset", typeof(SceneDirectory));

        if (dir == null)
        {
            DrawNewDirectoryButton();
        }
        else
        {
            SceneAsset deleteScene = null;

            for (int itr = 0; itr < dir.Scenes.Count; itr++)
            {
                SceneAsset scene = dir.Scenes[itr];

                if (scene == null)
                {
                    continue;
                }

                CustomEditorUtils.HeaderStart(scene.name);
                scene.sceneName = EditorGUILayout.TextField("Scene Name", scene.sceneName);

                EditorGUILayout.LabelField("Features");
                for (int itrFeature = 0; itrFeature < scene.features.Count; itrFeature++)
                {
                    EditorGUILayout.BeginHorizontal();
                    scene.features[itrFeature] = EditorGUILayout.TextField("Feature #" + (itrFeature + 1).ToString(), scene.features[itrFeature]);

                    if (GUILayout.Button("Delete Feature"))
                    {
                        scene.features.RemoveAt(itrFeature);
                        itrFeature--;
                        continue;
                    }

                    EditorGUILayout.EndHorizontal();
                }

                EditorGUILayout.BeginHorizontal();

                if (GUILayout.Button("Add New Feature"))
                {
                    scene.features.Add("");
                }

                if (GUILayout.Button("Delete"))
                {
                    deleteScene = scene;
                }

                EditorGUILayout.EndHorizontal();

                CustomEditorUtils.HeaderEnd();
            }

            if (deleteScene != null)
            {
                dir.Scenes.Remove(deleteScene);
                DestroyImmediate(deleteScene, true);
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
            }

            DrawCreateNewSceneAssetButton(dir);

            if (GUILayout.Button("Save Assets"))
            {
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
            }
        }

        if (dir != null)
        {
            // Necessary, otherwise data will be lost if window is open on entering play mode
            EditorUtility.SetDirty(dir);

            foreach (SceneAsset scene in dir.Scenes)
            {
                EditorUtility.SetDirty(scene);
            }
        }
    }