コード例 #1
0
    void OnGUI()
    {
        //   添加滑动条,高度不够时会自动隐藏
        scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(Screen.width), GUILayout.Height(Screen.height));

        #region 这里是显示最上面图片和字符串的
        GUI.DrawTexture(new Rect(20, 20, logo.width, logo.height), logo);

        GUILayout.Label("\n");
        GUILayout.Label("\n");
        GUILayout.Label("\n");
        GUILayout.Label("\n");

        string title = "\n" +
                       "   ==============" + "\n" +
                       "   **********************" + "\n" +
                       "   *  Author : TheNO.5   *" + "\n" +
                       "   **********************" + "\n" +
                       "   ==============";

        GUIStyle lableStyle = new GUIStyle();
        lableStyle.normal.background = null;
        lableStyle.normal.textColor  = new Color(0, 1, 0);
        lableStyle.fontSize          = 20;
        GUILayout.Label(title, lableStyle);
        GUILayout.Label("\n");
        #endregion



        #region  打开工具

        //  第一个折叠箭头控制
        show1 = EditorGUILayout.Foldout(show1, str1);
        if (show1)
        {
            if (GUILayout.Button("Change XML To SQLiteDB"))
            {
                LETools.XMLToSQLiteDatabase();
            }
        }
        #endregion


        EditorGUILayout.Space(); //  插入小缝隙,避免两个控件相邻太近。也可用GUILayout.Label("\n");
        EditorGUILayout.Space();
        EditorGUILayout.Space();


        #region  打开示例
        GUILayout.Label("以下是编辑器UI示例(点击打开)", lableStyle);
        GUILayout.Label("(按下示例箭头,右侧出现滚动条)");

        //  第二个折叠箭头控制
        show2 = EditorGUILayout.Foldout(show2, "打开示例");
        if (show2)
        {
            GUILayout.Label("\n");

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("我是文本输入框");
            string text = EditorGUILayout.TextField("Write something");
            EditorGUILayout.EndHorizontal();


            isToggle  = EditorGUILayout.BeginToggleGroup("我是Toggle", isToggle);
            toggle[0] = EditorGUILayout.Toggle("X", toggle[0]);
            toggle[1] = EditorGUILayout.Toggle("Y", toggle[1]);
            toggle[2] = EditorGUILayout.Toggle("Z", toggle[2]);
            EditorGUILayout.EndToggleGroup();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("选择渲染层");
            LayerMask layer = EditorGUILayout.LayerField(layerNO);
            EditorGUILayout.EndHorizontal();


            GUILayout.Label("\n");
            GUILayout.Label("\n");

            EditorGUILayout.LabelField("更多UI设置,请参考:", lableStyle);
            EditorGUILayout.Space();
            EditorGUILayout.TextField("http://www.ceeger.com/Script/EditorGUILayout/EditorGUILayout.html");

            GUILayout.Label("\n");
        }

        #endregion
        EditorGUILayout.EndScrollView();
    }
コード例 #2
0
    public override void OnInspectorGUI()
    {
        this.serializedObject.Update();

        GUIContent content;

        EditorGUI.indentLevel = 0;

        EditorGUIUtility.labelWidth = PGEditorUtils.CONTROLS_DEFAULT_LABEL_WIDTH;

        Object[] targetObjs = this.serializedObject.targetObjects;

        EventTrigger curEditTarget;

        if (InstanceManager.POOLING_ENABLED)
        {
            content = new GUIContent
                      (
                "PoolName",
                "The name of a pool to be used with PoolManager or other pooling solution. If " +
                "not using pooling, this will do nothing and be hidden in the Inspector. "
                      );
            EditorGUILayout.PropertyField(this.poolName, content);
        }

        content = new GUIContent
                  (
            "Hit Layers",
            "The layers in which the Area is allowed to find targets."
                  );
        EditorGUILayout.PropertyField(this.targetLayers, content);


        content = new GUIContent
                  (
            "Hit Mode",
            "Determines what should cause this EventTrigger to fire.\n" +
            "    TargetOnly\n" +
            "        Only a direct hit will trigger the OnFire event\n" +
            "    HitLayers\n" +
            "        Contact with any colliders in any of the layers in\n" +
            "        the HitLayers mask  will trigger the OnFire event."
                  );
        EditorGUILayout.PropertyField(this.hitMode, content);


        content = new GUIContent
                  (
            "listenTimeout (0 = OFF)",
            "An optional timer to allow this EventTrigger to timeout and self-destruct. When " +
            "set to a value above zero, when this reaches 0, the Fire coroutine will be " +
            "started and anything in range may be hit (depending on settings). This can be " +
            "used to give a projectile a max amount of time it can fly around before it " +
            "dies, or a time-based land mine or pick-up."
                  );
        EditorGUILayout.PropertyField(this.listenTimeout, content);

        content = new GUIContent
                  (
            "Fire On Spawn",
            "If true, the event will be fired as soon as this EventTrigger is spawned by " +
            "instantiation or pooling."
                  );
        EditorGUILayout.PropertyField(this.fireOnSpawn, content);

        content = new GUIContent
                  (
            "Fire On Sleep",
            "If this EventTrigger has a rigidbody, setting this to true will cause it to " +
            "fire if it falls asleep. See Unity's docs for more information on how " +
            "this happens."
                  );
        EditorGUILayout.PropertyField(this.fireOnRigidBodySleep, content);

        content = new GUIContent
                  (
            "Area Hit",
            "If true, more than just the primary target will be affected when this EventTrigger " +
            "fires. Use the range options to determine the behavior."
                  );
        EditorGUILayout.PropertyField(this.areaHit, content);

        // To make the gizmo delay work correctly, update the GUI here.
        serializedObject.ApplyModifiedProperties();

        if (this.areaHit.boolValue)
        {
            this.overrideGizmoVisibility.boolValue = false;

            EditorGUI.indentLevel += 1;

            content = new GUIContent(
                "Targets (-1 = all)",
                "The number of targets to return. Set to -1 to return all targets"
                );
            EditorGUILayout.PropertyField(this.numberOfTargets, content);


            content = new GUIContent("Sorting Style", "The style of sorting to use");
            EditorGUILayout.PropertyField(this.sortingStyle, content);

            var sortingStyle = (EventTrigger.SORTING_STYLES) this.sortingStyle.enumValueIndex;
            if (sortingStyle != EventTrigger.SORTING_STYLES.None)
            {
                EditorGUI.indentLevel += 1;

                content = new GUIContent(
                    "Minimum Interval",
                    "How often the target list will be sorted. If set to 0, " +
                    "sorting will only be triggered when Targets enter or exit range."
                    );
                EditorGUILayout.PropertyField(this.updateInterval, content);

                EditorGUI.indentLevel -= 1;
            }


            EditorGUI.BeginChangeCheck();
            content = new GUIContent
                      (
                "Area Layer",
                "The layer to put the Area in."
                      );
            content = EditorGUI.BeginProperty(new Rect(0, 0, 0, 0), content, this.areaLayer);

            int layer = EditorGUILayout.LayerField(content, this.areaLayer.intValue);

            // If changed, trigger the property setter for all objects being edited
            if (EditorGUI.EndChangeCheck())
            {
                for (int i = 0; i < targetObjs.Length; i++)
                {
                    curEditTarget = (EventTrigger)targetObjs[i];

                    Undo.RecordObject(curEditTarget, targetObjs[0].GetType() + " Area Layer");

                    curEditTarget.areaLayer = layer;
                }
            }
            EditorGUI.EndProperty();


            EditorGUILayout.BeginHorizontal();

            EditorGUI.BeginChangeCheck();
            content = new GUIContent
                      (
                "Area Shape",
                "The shape of the Area used to detect targets in range"
                      );
            EditorGUILayout.PropertyField(this.areaShape, content);

            // If changed, trigger the property setter for all objects being edited
            if (EditorGUI.EndChangeCheck())
            {
                var shape = (AreaTargetTracker.AREA_SHAPES) this.areaShape.enumValueIndex;

                for (int i = 0; i < targetObjs.Length; i++)
                {
                    curEditTarget = (EventTrigger)targetObjs[i];

                    Undo.RecordObject(curEditTarget, targetObjs[0].GetType() + " areaShape");

                    curEditTarget.areaShape = shape;
                }
            }

            content = new GUIContent
                      (
                "Gizmo ",
                "Visualize the Area in the Editor by turning this on."
                      );
            PGEditorUtils.ToggleButton(this.drawGizmo, content, 50);

            EditorGUILayout.EndHorizontal();

            if (this.drawGizmo.boolValue)
            {
                EditorGUI.indentLevel += 1;
                EditorGUILayout.BeginHorizontal();

                content = new GUIContent
                          (
                    "Gizmo Color",
                    "The color of the gizmo when displayed"
                          );
                EditorGUILayout.PropertyField(this.gizmoColor, content);

                // If clicked, reset the color to the default
                GUIStyle style = EditorStyles.miniButton;
                style.alignment  = TextAnchor.MiddleCenter;
                style.fixedWidth = 52;
                if (GUILayout.Button("Reset", style))
                {
                    for (int i = 0; i < this.serializedObject.targetObjects.Length; i++)
                    {
                        curEditTarget            = (EventTrigger)this.serializedObject.targetObjects[i];
                        curEditTarget.gizmoColor = curEditTarget.defaultGizmoColor;
                    }
                }

                EditorGUILayout.EndHorizontal();

                EditorGUI.indentLevel -= 1;

                GUILayout.Space(4);
            }

            content = new GUIContent
                      (
                "Duration (<0 = stay)",
                "An optional duration to control how long this EventTrigger stays active. " +
                "Each target will only be hit once with the event notification unless the " +
                "Target leaves and then re-enters range. Set this to -1 to keep it alive " +
                "forever."
                      );
            EditorGUILayout.PropertyField(this.duration, content);

            serializedObject.ApplyModifiedProperties();

            if (this.duration.floatValue > 0)
            {
                EditorGUI.indentLevel += 1;

                content = new GUIContent
                          (
                    "Start Range",
                    "When duration is greater than 0 this can be used have the range change " +
                    "over the course of the duration. This is used for things like a " +
                    "chockwave from a large explosion, which grows over time. "
                          );
                content = EditorGUI.BeginProperty(new Rect(0, 0, 0, 0), content, this.startRange);

                EditorGUI.BeginChangeCheck();
                Vector3 startRange = this.startRange.vector3Value;
                switch ((AreaTargetTracker.AREA_SHAPES) this.areaShape.enumValueIndex)
                {
                case AreaTargetTracker.AREA_SHAPES.Circle2D:                  // Fallthrough
                case AreaTargetTracker.AREA_SHAPES.Sphere:
                    startRange.x = EditorGUILayout.FloatField(content, startRange.x);
                    startRange.y = startRange.x;
                    startRange.z = startRange.x;
                    break;

                case AreaTargetTracker.AREA_SHAPES.Box2D:
                    float oldZ = startRange.z;
                    startRange   = EditorGUILayout.Vector2Field(content.text, startRange);
                    startRange.z = oldZ;                      // Nice to maintain if switching between 2D and 3D
                    break;

                case AreaTargetTracker.AREA_SHAPES.Box:
                    startRange = EditorGUILayout.Vector3Field(content.text, startRange);
                    break;

                case AreaTargetTracker.AREA_SHAPES.Capsule:
                    startRange   = EditorGUILayout.Vector2Field(content.text, startRange);
                    startRange.z = startRange.x;
                    break;
                }

                // Only assign the value back if it was actually changed by the user.
                // Otherwise a single value will be assigned to all objects when multi-object
                // editing, even when the user didn't touch the control.
                if (EditorGUI.EndChangeCheck())
                {
                    this.startRange.vector3Value = startRange;
                }

                EditorGUI.EndProperty();

                EditorGUI.indentLevel -= 1;
            }


            this.displayRange <EventTrigger>(targetObjs);


            EditorGUI.BeginChangeCheck();
            content = new GUIContent
                      (
                "Position Offset",
                "An optional position offset for the Area. For example, if you have an" +
                "object resting on the ground which has a range of 4, a position offset of" +
                "Vector3(0, 4, 0) will place your Area so it is also sitting on the ground."
                      );
            EditorGUILayout.PropertyField(this.areaPositionOffset, content);

            // If changed, trigger the property setter for all objects being edited
            if (EditorGUI.EndChangeCheck())
            {
                string undo_message = targetObjs[0].GetType() + " areaPositionOffset";

                for (int i = 0; i < targetObjs.Length; i++)
                {
                    curEditTarget = (EventTrigger)targetObjs[i];

                    Undo.RecordObject(curEditTarget, undo_message);

                    curEditTarget.areaPositionOffset = this.areaPositionOffset.vector3Value;
                }
            }


            EditorGUI.BeginChangeCheck();
            content = new GUIContent
                      (
                "Rotation Offset",
                "An optional rotational offset for the Area."
                      );
            EditorGUILayout.PropertyField(this.areaRotationOffset, content);

            // If changed, trigger the property setter for all objects being edited
            if (EditorGUI.EndChangeCheck())
            {
                string undo_message = targetObjs[0].GetType() + " areaPositionOffset";
                for (int i = 0; i < targetObjs.Length; i++)
                {
                    curEditTarget = (EventTrigger)targetObjs[i];

                    Undo.RecordObject(curEditTarget, undo_message);

                    curEditTarget.areaRotationOffset = this.areaRotationOffset.vector3Value;
                }
            }

            GUILayout.Space(8);
        }
        else
        {
            this.overrideGizmoVisibility.boolValue = true;
        }

        content = new GUIContent
                  (
            "Notify Targets",
            "Sets the target notification behavior. Telling targets they are hit is optional " +
            "for situations where a delayed response is required, such as launching a , " +
            "projectile or for custom handling.\n" +
            "\n" +
            "MODES\n" +
            "    Off\n" +
            "        Do not notify anything. delegates can still be used\n" +
            "        for custom handling\n" +
            "    Direct\n" +
            "        OnFire targets will be notified immediately\n" +
            "    PassInfoToEventTrigger\n" +
            "        For every Target hit, a new EventTrigger will be\n" +
            "        spawned and passed this EventTrigger's \n" +
            "        EventInfo. PassToEventTriggerOnce is more \n" +
            "        commonly used when secondary EventTrigger is\n" +
            "        needed, but this can be used for some creative\n" +
            "        or edge use-cases.\n" +
            "    PassInfoToEventTriggerOnce\n" +
            "        OnFire a new EventTrigger will be spawned and\n" +
            "        passed this EventTrigger's EventInfo. Only 1 will\n" +
            "        be spawned. This is handy for making bombs \n" +
            "        where only the first Target would trigger the \n" +
            "        event and only 1 EventTrigger would be spawned\n" +
            "        to expand over time (using duration and start\n" +
            "        range attributes).\n" +
            "    UseEventTriggerInfo\n" +
            "        Same as PassInfoToEventTrigger but the new\n" +
            "        EventTrigger will use its own EventInfo (this \n" +
            "        EventTrigger's EventInfo will be ignored).\n" +
            "    UseEventTriggerInfoOnce\n" +
            "        Same as PassInfoToEventTriggerOnce but the new\n" +
            "        EventTrigger will will used its own EventInfo\n" +
            "        (this EventTrigger's EventInfo will be ignored)."
                  );
        EditorGUILayout.PropertyField(this.notifyTargets, content);

        //
        // If using EventTrigger...
        //
        EventTrigger.NOTIFY_TARGET_OPTIONS curOption;
        curOption = (EventTrigger.NOTIFY_TARGET_OPTIONS) this.notifyTargets.enumValueIndex;
        if (curOption > EventTrigger.NOTIFY_TARGET_OPTIONS.Direct)
        {
            EditorGUI.indentLevel += 1;

            content = new GUIContent
                      (
                "EventTrigger Prefab",
                "An optional prefab to instance another EventTrigger. This can be handy if you " +
                "want to use a 'one-shot' event trigger to then spawn one that expands over " +
                "time using the duration and startRange to simulate a huge explosion."

                      );

            EditorGUILayout.PropertyField(this.eventTriggerPrefab, content);

            if (InstanceManager.POOLING_ENABLED)
            {
                EditorGUI.indentLevel += 1;
                if (this.eventTriggerPrefab.objectReferenceValue != null)
                {
                    content = new GUIContent
                              (
                        "Use Pooling",
                        "If false, do not add the new instance to a pool. Use Unity's " +
                        "Instantiate/Destroy"
                              );

                    EditorGUILayout.PropertyField(this.usePooling, content);

                    if (this.usePooling.boolValue)
                    {
                        content = new GUIContent
                                  (
                            "Override Pool Name",
                            "If an eventTriggerPrefab is spawned, setting this to true will " +
                            "override the EventTrigger's poolName and use this instead. The " +
                            "instance will also be passed this EventTrigger's " +
                            "eventTriggerPoolName to be used when the EventTrigger is " +
                            "desapwned."
                                  );

                        EditorGUILayout.PropertyField(this.overridePoolName, content);

                        if (this.overridePoolName.boolValue)
                        {
                            content = new GUIContent
                                      (
                                "Pool Name",
                                "The name of a pool to be used with PoolManager or other " +
                                "pooling solution. If not using pooling, this will do " +
                                "nothing and be hidden in the Inspector.\n" +
                                "WARNING: If poolname is set to '', Pooling will be " +
                                "disabled and Unity's Instantiate will be used."
                                      );

                            EditorGUILayout.PropertyField(this.eventTriggerPoolName, content);
                        }
                    }

                    EditorGUI.indentLevel -= 1;
                }
                else
                {
                    this.overridePoolName.boolValue = false;                      // Reset
                }
            }

            EditorGUI.indentLevel -= 1;
        }

        if (curOption < EventTrigger.NOTIFY_TARGET_OPTIONS.UseEventTriggerInfo)
        {
            if (this.serializedObject.isEditingMultipleObjects)
            {
                content = new GUIContent
                          (
                    "Event Info List",
                    "A list of EventInfo structs which hold one or more event descriptions of how " +
                    "this EventTrigger can affect a Target."
                          );
                EditorGUILayout.PropertyField(this.eventInfoList, content, true);
            }
            else
            {
                EditorGUI.indentLevel += 2;

                curEditTarget        = (EventTrigger)targetObjs[0];
                this.expandEventInfo = PGEditorUtils.SerializedObjFoldOutList <EventInfoListGUIBacker>
                                       (
                    "Event Info List",
                    curEditTarget._eventInfoList,
                    this.expandEventInfo,
                    ref curEditTarget._editorListItemStates,
                    true
                                       );

                EditorGUI.indentLevel -= 2;
            }
        }

        GUILayout.Space(4);

        content = new GUIContent
                  (
            "Debug Level", "Set it higher to see more verbose information."
                  );
        EditorGUILayout.PropertyField(this.debugLevel, content);

        serializedObject.ApplyModifiedProperties();

        // Flag Unity to save the changes to to the prefab to disk
        //   This is needed to make the gizmos update immediatly.
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
コード例 #3
0
    /// <summary>
    /// Draws the window content: object list, configuration and execution buttons.
    /// </summary>
    void OnGUI()
    {
        #region Draw Top Buttons

        GUILayout.BeginHorizontal(EditorStyles.toolbar);
        {
            editMode = GUILayout.Toggle(editMode, new GUIContent("Start replacing", "Start using this feature"), EditorStyles.toggle);
            GUILayout.FlexibleSpace();
        }
        GUILayout.EndHorizontal();
        #endregion

        #region "TAG LAYER"

        SearchWithTag   = GUILayout.Toggle(!SearchWithLayer ? SearchWithTag : false, "Apply Search By Tag", EditorStyles.toggle);
        SearchWithLayer = GUILayout.Toggle(!SearchWithTag ? SearchWithLayer : false, "Apply Search By Layer");

        if (SearchWithTag)
        {
            GUILayout.Space(5);
            TagForSearch = EditorGUILayout.TagField("Set tag :  ", TagForSearch);
        }
        else if (SearchWithLayer)
        {
            GUILayout.Space(5);
            LayerForSearch = EditorGUILayout.LayerField("Set layer :  ", LayerForSearch);
        }
        #endregion "TAG LAYER"

        if (GUI.changed)
        {
            if (editMode)
            {
                GetSelection();
            }
            else
            {
                ResetPreview();
            }
        }

        GUILayout.Space(10);
        if (editMode)
        {
            SetNamingScheme();
            RenamePreview();

            #region Draw Prefab and List

            GUILayout.Label("Prefab: ", EditorStyles.boldLabel);
            prefab = (GameObject)EditorGUILayout.ObjectField(prefab, typeof(GameObject), true);
            if (oldPrefab != prefab)
            {
                GetSelection();
                oldPrefab = prefab;
            }
            GUILayout.Space(10);

            if (prefab != null)
            {
                if (objectsToReplace.Count > 0)
                {
                    GUILayout.Label(new GUIContent("Objects to be Replaced:", (!SearchWithTag && !SearchWithLayer) ? "Multi-select all the objects you want to replace with your Prefab" : ""), EditorStyles.boldLabel);

                    objectPreview.Sort(new NaturalComparer());

                    scrollPosition = GUILayout.BeginScrollView(scrollPosition, EditorStyles.helpBox);
                    {
                        GUILayout.BeginHorizontal(EditorStyles.helpBox);
                        {
                            string previewText = "No Preview";

                            if (replacementPreferences.renameObjects && !replacementPreferences.orderHierarchyToPreview)
                            {
                                previewText = "Preview of Renaming";
                            }
                            else if (replacementPreferences.orderHierarchyToPreview && !replacementPreferences.renameObjects)
                            {
                                previewText = "Preview of Hierarchy Order";
                            }
                            else if (replacementPreferences.orderHierarchyToPreview && replacementPreferences.renameObjects)
                            {
                                previewText = "Preview of Renaming and Hierarchy Order";
                            }

                            GUILayout.Label(previewText, EditorStyles.miniLabel);
                        }
                        GUILayout.EndHorizontal();

                        foreach (string go in objectPreview)
                        {
                            GUILayout.BeginHorizontal(EditorStyles.toolbar);
                            GUILayout.Label(go);
                            GUILayout.EndHorizontal();
                        }
                        GUILayout.Space(2);
                    }
                    GUILayout.EndScrollView();

                    GUILayout.Space(5);

                    replacementPreferences.renameObjects           = GUILayout.Toggle(replacementPreferences.renameObjects, "Rename replaced objects", EditorStyles.toggle);
                    replacementPreferences.orderHierarchyToPreview = GUILayout.Toggle(replacementPreferences.orderHierarchyToPreview, "Oder hierarchy to preview", EditorStyles.toggle);
                    GUILayout.Space(10);
                    replacementPreferences.applyRotation = GUILayout.Toggle(replacementPreferences.applyRotation, "Apply rotation", EditorStyles.toggle);
                    replacementPreferences.applyScale    = GUILayout.Toggle(replacementPreferences.applyScale, "Apply scale", EditorStyles.toggle);
                }
                else if (!SearchWithTag && !SearchWithLayer)
                {
                    GUILayout.Label(new GUIContent("Multi-select all the objects you want to replace with your Prefab"), EditorStyles.boldLabel);
                }
            }
            else
            {
                GUILayout.Label("Select a Prefab to replace objects with", EditorStyles.boldLabel);
            }
            #endregion

            #region Draw Bottom Buttons

            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            {
                if (prefab != null && objectsToReplace.Count > 0)
                {
                    if (GUILayout.Button("Apply"))
                    {
                        foreach (GameObject go in objectsToReplace)
                        {
                            Replace(go);
                            DestroyImmediate(go);
                        }
                        if (replacementPreferences.renameObjects)
                        {
                            Rename();
                        }
                        editMode = false;
                        EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());     // Important so that we don't forget to save!
                    }
                    else if (GUILayout.Button("Cancel"))
                    {
                        objectsToReplace.Clear();
                        objectPreview.Clear();
                        ResetPreview();
                        prefab = null;
                    }
                }
            }
            GUILayout.EndHorizontal();
            #endregion
        }
        else
        {
            objectsToReplace.Clear();
            objectPreview.Clear();
            newObjects.Clear();
            prefab = null;
        }
    }
コード例 #4
0
ファイル: tk2dTileMapEditor.cs プロジェクト: wuzhida/YUMI
    void DrawLayersPanel(bool allowEditing)
    {
        GUILayout.BeginVertical();

        // constrain selected layer
        editorData.layer = Mathf.Clamp(editorData.layer, 0, tileMap.data.NumLayers - 1);

        if (allowEditing)
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Add Layer", EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
            {
                editorData.layer = tk2dEditor.TileMap.TileMapUtility.AddNewLayer(tileMap);
            }
            GUILayout.EndHorizontal();
        }

        GUILayout.BeginVertical();

        int numLayers   = tileMap.data.NumLayers;
        int deleteLayer = -1;
        int moveUp      = -1;
        int moveDown    = -1;

        for (int layer = numLayers - 1; layer >= 0; --layer)
        {
            GUILayout.BeginHorizontal(tk2dEditorSkin.SC_ListBoxItem);
            if (allowEditing && editorData.layer == layer)
            {
                string newName = GUILayout.TextField(tileMap.data.Layers[layer].name, EditorStyles.label, GUILayout.ExpandWidth(true));
                tileMap.data.Layers[layer].name = newName;
            }
            else
            {
                if (allowEditing)
                {
                    if (GUILayout.Button(tileMap.data.Layers[layer].name, EditorStyles.label, GUILayout.ExpandWidth(true)))
                    {
                        editorData.layer = layer;
                        Repaint();
                    }
                }
                else
                {
                    bool layerSelVal    = editorData.layer == layer;
                    bool newLayerSelVal = GUILayout.Toggle(layerSelVal, tileMap.data.Layers[layer].name, EditorStyles.toggle, GUILayout.ExpandWidth(true));
                    if (newLayerSelVal != layerSelVal)
                    {
                        editorData.layer = layer;
                        Repaint();
                    }
                }
            }

            if (allowEditing)
            {
                GUILayout.FlexibleSpace();
                GUILayout.BeginVertical();

                GUILayout.BeginHorizontal();

                GUILayout.FlexibleSpace();

                tk2dGuiUtility.BeginChangeCheck();
                tileMap.data.Layers[layer].useColor = GUILayout.Toggle(tileMap.data.Layers[layer].useColor, "Color", EditorStyles.miniButton, GUILayout.ExpandWidth(false));
                if (tk2dGuiUtility.EndChangeCheck())
                {
                    Build(true);
                }

                tileMap.data.Layers[layer].generateCollider = GUILayout.Toggle(tileMap.data.Layers[layer].generateCollider, "Collider", EditorStyles.miniButton, GUILayout.ExpandWidth(false));

                if (allowEditing && tileMap.data.NumLayers != 1)
                {
                    GUIContent moveLayerDownLabel = new GUIContent("D", "Move layer down");
                    GUIContent moveLayerUpLabel   = new GUIContent("U", "Move layer up");
                    GUIContent deleteLayerLabel   = new GUIContent("X", "Delete layer");

                    if (layer != 0)
                    {
                        if (GUILayout.Button(moveLayerDownLabel, EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
                        {
                            moveUp = layer;
                            Repaint();
                        }
                    }
                    else
                    {
                        GUILayout.Label(moveLayerDownLabel, EditorStyles.miniButton);
                    }

                    if (layer != numLayers - 1)
                    {
                        if (GUILayout.Button(moveLayerUpLabel, EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
                        {
                            moveDown = layer;
                            Repaint();
                        }
                    }
                    else
                    {
                        GUILayout.Label(moveLayerUpLabel, EditorStyles.miniButton);
                    }

                    if (GUILayout.Button(deleteLayerLabel, EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
                    {
                        deleteLayer = layer;
                        Repaint();
                    }
                }

                GUILayout.EndHorizontal();



                GUILayout.BeginHorizontal();

                GUILayout.FlexibleSpace();
                tk2dGuiUtility.BeginChangeCheck();
                if (layer == 0)
                {
                    EditorGUILayout.FloatField(0.0f, GUILayout.Width(50));
                }
                else
                {
                    tileMap.data.Layers[layer].z = EditorGUILayout.FloatField(tileMap.data.Layers[layer].z, GUILayout.Width(50));
                    tileMap.data.Layers[layer].z = Mathf.Max(0, tileMap.data.Layers[layer].z);
                }
                if (tk2dGuiUtility.EndChangeCheck())
                {
                    Build(true);
                }

                tk2dGuiUtility.BeginChangeCheck();
                tileMap.data.Layers[layer].unityLayer = EditorGUILayout.LayerField(tileMap.data.Layers[layer].unityLayer, GUILayout.Width(90.0f));
                if (tk2dGuiUtility.EndChangeCheck())
                {
                    Build(true);
                }

                GUILayout.EndHorizontal();


                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();
        }

        if (deleteLayer != -1)
        {
            Undo.RegisterUndo(new Object[] { tileMap, tileMap.data }, "Deleted layer");
            tk2dEditor.TileMap.TileMapUtility.DeleteLayer(tileMap, deleteLayer);
        }

        if (moveUp != -1)
        {
            Undo.RegisterUndo(new Object[] { tileMap, tileMap.data }, "Moved layer");
            tk2dEditor.TileMap.TileMapUtility.MoveLayer(tileMap, moveUp, -1);
        }

        if (moveDown != -1)
        {
            Undo.RegisterUndo(new Object[] { tileMap, tileMap.data }, "Moved layer");
            tk2dEditor.TileMap.TileMapUtility.MoveLayer(tileMap, moveDown, 1);
        }

        GUILayout.EndVertical();

        GUILayout.EndVertical();
    }
コード例 #5
0
ファイル: ConfigEditor.cs プロジェクト: NNNNateLiu/Studio2
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            bool reloadNoise = false;

            bool isUsedInstance = (Object)Config.Instance == this.target;

            if (!IsOverriddenInstance())
            {
                if (isUsedInstance)
                {
                    if (GUILayout.Button(EditorStrings.ConfigCreateOverrideAsset))
                    {
                        ConfigOverrideEditor.CreateAsset();
                    }
                }
                else
                {
                    ButtonOpenConfig(/*miniButton*/ false);
                }
                DrawLineSeparator();
            }

            if (IsOverriddenInstance() && !isUsedInstance)
            {
                EditorGUILayout.HelpBox(EditorStrings.ConfigMultipleAssets, MessageType.Error);
                EditorGUILayout.Separator();
                ButtonOpenConfig();
            }
            else
            {
                EditorGUI.BeginDisabledGroup(IsDisabled());
                {
                    EditorGUI.BeginChangeCheck();
                    {
                        if (HeaderFoldable("Beam Geometry"))
                        {
                            using (new EditorGUILayout.HorizontalScope())
                            {
                                geometryOverrideLayer.boolValue = EditorGUILayout.Toggle(EditorStrings.ConfigGeometryOverrideLayer, geometryOverrideLayer.boolValue);
                                using (new EditorGUI.DisabledGroupScope(!geometryOverrideLayer.boolValue))
                                {
                                    geometryLayerID.intValue = EditorGUILayout.LayerField(geometryLayerID.intValue);
                                }
                            }

                            geometryTag.stringValue = EditorGUILayout.TagField(EditorStrings.ConfigGeometryTag, geometryTag.stringValue);
                        }
                        DrawLineSeparator();

                        if (HeaderFoldable("Rendering"))
                        {
                            RenderQueueGUIDraw();

                            if (BeamGeometry.isCustomRenderPipelineSupported)
                            {
                                EditorGUI.BeginChangeCheck();
                                {
                                    renderPipeline.CustomEnum <RenderPipeline>(EditorStrings.ConfigGeometryRenderPipeline, EditorStrings.ConfigGeometryRenderPipelineEnumDescriptions);
                                }
                                if (EditorGUI.EndChangeCheck())
                                {
                                    Config.OnRenderPipelineChanged((RenderPipeline)renderPipeline.enumValueIndex);
                                    VolumetricLightBeam._EditorSetAllBeamGeomDirty(); // need to fully reset the BeamGeom to update the shader
                                    ReimportShaders();
                                }
                            }

                            EditorGUI.BeginChangeCheck();
                            {
                                EditorGUILayout.PropertyField(renderingMode, EditorStrings.ConfigGeometryRenderingMode);

                                if (renderPipeline.enumValueIndex == (int)RenderPipeline.SRP_4_0_0_or_higher && renderingMode.enumValueIndex == (int)RenderingMode.MultiPass)
                                {
                                    EditorGUILayout.HelpBox(EditorStrings.ConfigSrpAndMultiPassNoCompatible, MessageType.Error);
                                }

#pragma warning disable 0162 // warning CS0162: Unreachable code detected
                                if (renderingMode.enumValueIndex == (int)RenderingMode.GPUInstancing && !GpuInstancing.isSupported)
                                {
                                    EditorGUILayout.HelpBox(EditorStrings.ConfigGeometryGpuInstancingNotSupported, MessageType.Warning);
                                }
#pragma warning restore 0162
                            }
                            if (EditorGUI.EndChangeCheck())
                            {
                                VolumetricLightBeam._EditorSetAllBeamGeomDirty(); // need to fully reset the BeamGeom to update the shader
                                GlobalMesh.Destroy();
                                ReimportShaders();
                            }
                        }
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        VolumetricLightBeam._EditorSetAllMeshesDirty();
                    }
                    DrawLineSeparator();

                    if (HeaderFoldable("Shared Mesh"))
                    {
                        EditorGUI.BeginChangeCheck();
                        EditorGUILayout.PropertyField(sharedMeshSides, EditorStrings.ConfigSharedMeshSides);
                        EditorGUILayout.PropertyField(sharedMeshSegments, EditorStrings.ConfigSharedMeshSegments);
                        if (EditorGUI.EndChangeCheck())
                        {
                            GlobalMesh.Destroy();
                            VolumetricLightBeam._EditorSetAllMeshesDirty();
                        }

                        var meshInfo = "These properties will change the mesh tessellation of each Volumetric Light Beam with 'Shared' MeshType.\nAdjust them carefully since they could impact performance.";
                        meshInfo += string.Format("\nShared Mesh stats: {0} vertices, {1} triangles", MeshGenerator.GetSharedMeshVertexCount(), MeshGenerator.GetSharedMeshIndicesCount() / 3);
                        EditorGUILayout.HelpBox(meshInfo, MessageType.Info);
                    }
                    DrawLineSeparator();

                    if (HeaderFoldable("Global 3D Noise"))
                    {
                        EditorGUILayout.PropertyField(globalNoiseScale, EditorStrings.ConfigGlobalNoiseScale);
                        EditorGUILayout.PropertyField(globalNoiseVelocity, EditorStrings.ConfigGlobalNoiseVelocity);
                    }
                    DrawLineSeparator();

                    if (HeaderFoldable("Camera to compute Fade Out"))
                    {
                        EditorGUI.BeginChangeCheck();
                        fadeOutCameraTag.stringValue = EditorGUILayout.TagField(EditorStrings.ConfigFadeOutCameraTag, fadeOutCameraTag.stringValue);
                        if (EditorGUI.EndChangeCheck() && Application.isPlaying)
                        {
                            (target as Config).ForceUpdateFadeOutCamera();
                        }
                    }
                    DrawLineSeparator();

                    if (HeaderFoldable("Internal Data (do not change)"))
                    {
                        EditorGUILayout.PropertyField(beamShader1Pass, EditorStrings.ConfigBeamShader1Pass);
                        EditorGUILayout.PropertyField(beamShader2Pass, EditorStrings.ConfigBeamShader2Pass);
                        EditorGUILayout.PropertyField(dustParticlesPrefab, EditorStrings.ConfigDustParticlesPrefab);

                        EditorGUI.BeginChangeCheck();
                        EditorGUILayout.PropertyField(noise3DData, EditorStrings.ConfigNoise3DData);
                        EditorGUILayout.PropertyField(noise3DSize, EditorStrings.ConfigNoise3DSize);
                        if (EditorGUI.EndChangeCheck())
                        {
                            reloadNoise = true;
                        }

                        if (Noise3D.isSupported && !Noise3D.isProperlyLoaded)
                        {
                            EditorGUILayout.HelpBox(EditorStrings.HelpNoiseLoadingFailed, MessageType.Error);
                        }
                    }
                    DrawLineSeparator();

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        if (GUILayout.Button(EditorStrings.ConfigOpenDocumentation, EditorStyles.miniButton))
                        {
                            UnityEditor.Help.BrowseURL(Consts.HelpUrlConfig);
                        }

                        if (GUILayout.Button(EditorStrings.ConfigResetToDefaultButton, EditorStyles.miniButton))
                        {
                            UnityEditor.Undo.RecordObject(target, "Reset Config Properties");
                            (target as Config).Reset();
                        }
                    }
                }
                EditorGUI.EndDisabledGroup();
            }

            serializedObject.ApplyModifiedProperties();

            if (reloadNoise)
            {
                Noise3D._EditorForceReloadData(); // Should be called AFTER ApplyModifiedProperties so the Config instance has the proper values when reloading data
            }
        }
コード例 #6
0
        public override void Header()
        {
            var entities = Targets.Cast <UTinyEntity>();

            var firstEntity = entities.FirstOrDefault();

            if (null == firstEntity)
            {
                return;
            }

            UTinyGUI.BackgroundColor(new Rect(0, 0, Screen.width, 15 + 2 * UTinyGUIUtility.SingleLineAndSpaceHeight), UTinyColors.Inspector.HeaderBackground);
            GUILayout.Space(10);
            var name = firstEntity.Name;

            name = entities.All(entity => entity.Name == name) ? name : "-";
            var enabled     = firstEntity.Enabled;
            var sameEnabled = entities.All(tiny => tiny.Enabled == enabled);

            using (new EditorGUILayout.HorizontalScope())
            {
                EditorGUI.BeginChangeCheck();
                var mixed = EditorGUI.showMixedValue;
                EditorGUI.showMixedValue = !sameEnabled;
                enabled = EditorGUILayout.ToggleLeft(GUIContent.none, enabled, GUILayout.Width(EditorGUIUtility.singleLineHeight));
                EditorGUI.showMixedValue = mixed;
                if (EditorGUI.EndChangeCheck())
                {
                    foreach (var entity in entities)
                    {
                        entity.Enabled = enabled;
                        entity.View.gameObject.SetActive(enabled);
                    }
                    UTinyHierarchyWindow.InvalidateDataModel();
                    UTinyEditorUtility.RepaintAllWindows();
                }
                EditorGUI.BeginChangeCheck();
                name = EditorGUILayout.DelayedTextField(name, UTinyStyles.ComponentHeaderStyle);
                if (EditorGUI.EndChangeCheck())
                {
                    foreach (var entity in entities)
                    {
                        entity.Name = name;
                    }
                    UTinyHierarchyWindow.InvalidateDataModel();
                    UTinyEditorUtility.RepaintAllWindows();
                }
                GUILayout.Space(EditorGUIUtility.singleLineHeight);
            }

            var layer     = firstEntity.Layer;
            var sameLayer = entities.All(tiny => tiny.Layer == layer);

            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.Space(50);
                EditorGUILayout.LabelField("Layer", GUILayout.Width(50));
                EditorGUI.BeginChangeCheck();
                var mixed = EditorGUI.showMixedValue;
                EditorGUI.showMixedValue = !sameLayer;
                layer = EditorGUILayout.LayerField(layer);
                if (EditorGUI.EndChangeCheck())
                {
                    foreach (var entity in entities)
                    {
                        entity.Layer = layer;
                        entity.View.gameObject.layer = layer;
                    }
                    UTinyHierarchyWindow.InvalidateDataModel();
                    UTinyEditorUtility.RepaintAllWindows();
                }
                GUILayout.Space(EditorGUIUtility.singleLineHeight);
                EditorGUI.showMixedValue = mixed;
            }
            GUILayout.Space(5);
            UTinyGUILayout.Separator(UTinyColors.Inspector.Separator, UTinyGUIUtility.ComponentHeaderSeperatorHeight);
        }
コード例 #7
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            GUIStyle foldoutStyle = EditorStyles.foldout;

            foldoutStyle.fontStyle = FontStyle.Bold;

            EditorGUILayout.Space();
            EditorUtility.SkinnedLabel("Editor");

            if (!runtimeOnlyMesh.boolValue)
            {
                if (serializedObject.targetObjects.Length < 2)
                {
                    if (GUILayout.Button(voxelObject.IsEnabledForEditing ? "Stop Editing" : "Start Editing"))
                    {
                        if (voxelObject.IsEnabledForEditing)
                        {
                            voxelObject.SaveForSerialize();
                        }

                        voxelObject.IsEnabledForEditing = !voxelObject.IsEnabledForEditing;
                        voxelObject.PaintMode           = EditorPaintMode.Color;

                        voxelObject.UpdateChunks(true);



                        SceneView.RepaintAll();
                    }
                    if (voxelObject.IsEnabledForEditing)
                    {
                        propogateAllFrames = EditorGUILayout.ToggleLeft(" Propagate edits to all frames",
                                                                        propogateAllFrames);

                        EditorGUILayout.BeginHorizontal();
                        drawGrid = EditorGUILayout.ToggleLeft(new GUIContent(" Draw Grid"), drawGrid);
                        if (drawGrid != voxelObject.DrawGrid)
                        {
                            voxelObject.DrawGrid = drawGrid;
                            SceneView.RepaintAll();
                        }
                        drawMesh = EditorGUILayout.ToggleLeft(new GUIContent(" Draw Wireframe"), drawMesh);
                        if (drawMesh != voxelObject.DrawMesh)
                        {
                            voxelObject.DrawMesh = drawMesh;
                            SceneView.RepaintAll();
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }

            runtimeOnlyMesh.boolValue = EditorGUILayout.ToggleLeft(new GUIContent(" Runtime-Only Mesh"),
                                                                   runtimeOnlyMesh.boolValue);
            if (runtimeOnlyMesh.boolValue != voxelObject.RuntimOnlyMesh)
            {
                foreach (var o in serializedObject.targetObjects)
                {
                    ((Volume)o).IsEnabledForEditing = false;
                    ((Volume)o).RuntimOnlyMesh      = runtimeOnlyMesh.boolValue;
                    ((Volume)o).CreateChunks();
                    ((Volume)o).UpdateAllChunks();
                }
            }

            EditorGUILayout.Space();

            EditorUtility.SkinnedLabel(
                "Size (Volume size: " + voxelObject.XSize + "," + voxelObject.YSize + "," + voxelObject.ZSize +
                " Chunk Size: " + voxelObject.XChunkSize + "," + voxelObject.YChunkSize + "," + voxelObject.ZChunkSize +
                ")");
            float size = EditorGUILayout.FloatField("Voxel Size:", voxelSizeProperty.floatValue);

            if (size != voxelSizeProperty.floatValue && size > 0f)
            {
                voxelSizeProperty.floatValue = size;
                voxelSize = voxelSizeProperty.floatValue;
                foreach (var o in serializedObject.targetObjects)
                {
                    ((Volume)o).VoxelSize = voxelSize;
                    ((Volume)o).CreateChunks();
                }
            }

            float overlap = EditorGUILayout.FloatField("Face Overlap:", overlapAmountProperty.floatValue);

            if (overlap != overlapAmountProperty.floatValue)
            {
                overlapAmountProperty.floatValue = overlap;
                overlapAmount = overlapAmountProperty.floatValue;
                foreach (var o in serializedObject.targetObjects)
                {
                    ((Volume)o).OverlapAmount = overlapAmount;
                    ((Volume)o).CreateChunks();
                }
            }

            if (serializedObject.targetObjects.Length < 2 && !voxelObject.IsEnabledForEditing)
            {
                if (GUILayout.Button("Resize"))
                {
                    EditorResizeWindow window =
                        (EditorResizeWindow)
                        EditorWindow.GetWindowWithRect((typeof(EditorResizeWindow)), new Rect(100, 100, 400, 240),
                                                       true);
                    window.Init(voxelObject);
                }

                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Rotate X"))
                {
                    voxelObject.RotateX();
                }
                if (GUILayout.Button("Rotate Y"))
                {
                    voxelObject.RotateY();
                }
                if (GUILayout.Button("Rotate Z"))
                {
                    voxelObject.RotateZ();
                }
                GUILayout.EndHorizontal();
            }

            EditorGUILayout.Space();
            EditorUtility.SkinnedLabel("Pivot");
            pivotProperty.vector3Value = EditorGUILayout.Vector3Field("", pivotProperty.vector3Value, null);
            if (pivotProperty.vector3Value != voxelObject.Pivot)
            {
                pivot = pivotProperty.vector3Value;
                foreach (var o in serializedObject.targetObjects)
                {
                    ((Volume)o).Pivot = pivot;
                    ((Volume)o).UpdatePivot();
                }
            }
            if (GUILayout.Button("Set to Center"))
            {
                pivot = (new Vector3(voxelObject.XSize, voxelObject.YSize, voxelObject.ZSize) * voxelObject.VoxelSize) / 2f;
                pivotProperty.vector3Value = pivot;
                foreach (var o in serializedObject.targetObjects)
                {
                    ((Volume)o).Pivot = pivot;
                    ((Volume)o).UpdatePivot();
                }
            }

            EditorGUILayout.Space();
            scrollFoldout = EditorGUILayout.Foldout(scrollFoldout, "Scroll Voxels", foldoutStyle);
            if (scrollFoldout)
            {
                //EditorUtility.SkinnedLabel("Scroll Voxels");
                allFrames = EditorGUILayout.ToggleLeft(" Scroll all frames", allFrames);
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("X-1"))
                {
                    voxelObject.ScrollX(-1, allFrames);
                }
                if (GUILayout.Button("X-10"))
                {
                    voxelObject.ScrollX(-10, allFrames);
                }
                if (GUILayout.Button("X+1"))
                {
                    voxelObject.ScrollX(1, allFrames);
                }
                if (GUILayout.Button("X+10"))
                {
                    voxelObject.ScrollX(10, allFrames);
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Y-1"))
                {
                    voxelObject.ScrollY(-1, allFrames);
                }
                if (GUILayout.Button("Y-10"))
                {
                    voxelObject.ScrollY(-10, allFrames);
                }
                if (GUILayout.Button("Y+1"))
                {
                    voxelObject.ScrollY(1, allFrames);
                }
                if (GUILayout.Button("Y+10"))
                {
                    voxelObject.ScrollY(10, allFrames);
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Z-1"))
                {
                    voxelObject.ScrollZ(-1, allFrames);
                }
                if (GUILayout.Button("Z-10"))
                {
                    voxelObject.ScrollZ(-10, allFrames);
                }
                if (GUILayout.Button("Z+1"))
                {
                    voxelObject.ScrollZ(1, allFrames);
                }
                if (GUILayout.Button("Z+10"))
                {
                    voxelObject.ScrollZ(10, allFrames);
                }
                GUILayout.EndHorizontal();
            }

            EditorGUILayout.Space();
            chunkFoldout = EditorGUILayout.Foldout(chunkFoldout, "Chunk Generation", foldoutStyle);
            if (chunkFoldout)
            {
                chunkLayer.intValue = EditorGUILayout.LayerField("Chunk Layer: ", chunkLayer.intValue);
                if (chunkLayer.intValue != voxelObject.ChunkLayer)
                {
                    foreach (var o in serializedObject.targetObjects)
                    {
                        ((Volume)o).ChunkLayer = chunkLayer.intValue;
                        ((Volume)o).CreateChunks();
                    }
                }

                EditorUtility.SkinnedLabel("Mesh Collider");
                collisionMode.enumValueIndex =
                    Convert.ToInt16(EditorGUILayout.EnumPopup((CollisionMode)collisionMode.enumValueIndex));
                if (collisionMode.enumValueIndex != Convert.ToInt16(voxelObject.CollisionMode))
                {
                    foreach (var o in serializedObject.targetObjects)
                    {
                        ((Volume)o).ChangeCollisionMode((CollisionMode)collisionMode.enumValueIndex);
                    }
                }
                if (collisionMode.enumValueIndex > 0)
                {
                    collisionTrigger.boolValue = EditorGUILayout.ToggleLeft(new GUIContent(" Is Trigger"),
                                                                            collisionTrigger.boolValue);
                    if (collisionTrigger.boolValue != voxelObject.CollisionTrigger)
                    {
                        foreach (var o in serializedObject.targetObjects)
                        {
                            ((Volume)o).CollisionTrigger = collisionTrigger.boolValue;
                            ((Volume)o).CreateChunks();
                        }
                    }

                    physicMaterial.objectReferenceValue = EditorGUILayout.ObjectField("Physic Material: ",
                                                                                      physicMaterial.objectReferenceValue,
                                                                                      typeof(PhysicMaterial),
                                                                                      false);
                    if (physicMaterial.objectReferenceValue != voxelObject.PhysicMaterial)
                    {
                        foreach (var o in serializedObject.targetObjects)
                        {
                            ((Volume)o).PhysicMaterial = (PhysicMaterial)physicMaterial.objectReferenceValue;
                            ((Volume)o).CreateChunks();
                        }
                    }

                    separateColliderMesh.boolValue =
                        EditorGUILayout.ToggleLeft(
                            new GUIContent(" Generate collider mesh separately (Edit-time only)"),
                            separateColliderMesh.boolValue);
                    if (separateColliderMesh.boolValue != voxelObject.GenerateMeshColliderSeparately)
                    {
                        foreach (var o in serializedObject.targetObjects)
                        {
                            ((Volume)o).GenerateMeshColliderSeparately = separateColliderMesh.boolValue;
                            ((Volume)o).CreateChunks();
                        }
                    }

                    if (separateColliderMesh.boolValue)
                    {
                        EditorUtility.SkinnedLabel("Collider Meshing Mode");
                        colliderMeshingMode.enumValueIndex =
                            Convert.ToInt16(EditorGUILayout.EnumPopup((MeshingMode)colliderMeshingMode.enumValueIndex));
                        if (colliderMeshingMode.enumValueIndex != Convert.ToInt16(voxelObject.MeshColliderMeshingMode))
                        {
                            foreach (var o in serializedObject.targetObjects)
                            {
                                ((Volume)o).MeshColliderMeshingMode = (MeshingMode)colliderMeshingMode.enumValueIndex;
                                ((Volume)o).CreateChunks();
                            }
                        }
                    }
                }

                EditorGUILayout.Space();

                EditorUtility.SkinnedLabel("Meshing Mode");
                meshingMode.enumValueIndex =
                    Convert.ToInt16(EditorGUILayout.EnumPopup((MeshingMode)meshingMode.enumValueIndex));
                if (meshingMode.enumValueIndex != Convert.ToInt16(voxelObject.MeshingMode))
                {
                    foreach (var o in serializedObject.targetObjects)
                    {
                        ((Volume)o).MeshingMode = (MeshingMode)meshingMode.enumValueIndex;
                        ((Volume)o).CreateChunks();
                    }
                }

                EditorUtility.SkinnedLabel("Mesh Compression");
                meshCompression.enumValueIndex =
                    Convert.ToInt16(
                        EditorGUILayout.EnumPopup((ModelImporterMeshCompression)meshCompression.enumValueIndex));
                if (meshCompression.enumValueIndex != Convert.ToInt16(voxelObject.MeshCompression))
                {
                    foreach (var o in serializedObject.targetObjects)
                    {
                        ((Volume)o).MeshCompression = (ModelImporterMeshCompression)meshCompression.enumValueIndex;
                        ((Volume)o).CreateChunks();
                    }
                }

                selfShadeInt.floatValue = EditorGUILayout.Slider("Self-Shading Intensity", selfShadeInt.floatValue, 0, 1);
                if (selfShadeInt.floatValue != voxelObject.SelfShadingIntensity)
                {
                    foreach (var o in serializedObject.targetObjects)
                    {
                        ((Volume)o).SelfShadingIntensity = selfShadeInt.floatValue;
                        ((Volume)o).UpdateAllChunks();
                    }
                }

                material.objectReferenceValue = EditorGUILayout.ObjectField("Material: ", material.objectReferenceValue,
                                                                            typeof(Material),
                                                                            false);
                if (material.objectReferenceValue != voxelObject.Material)
                {
                    foreach (var o in serializedObject.targetObjects)
                    {
                        ((Volume)o).Material = (Material)material.objectReferenceValue;
                        ((Volume)o).CreateChunks();
                    }
                }

                castShadows.enumValueIndex =
                    Convert.ToInt16(EditorGUILayout.EnumPopup("Cast Shadows",
                                                              (ShadowCastingMode)castShadows.enumValueIndex));
                if (castShadows.enumValueIndex != Convert.ToInt16(voxelObject.CastShadows))
                {
                    foreach (var o in serializedObject.targetObjects)
                    {
                        ((Volume)o).CastShadows = (ShadowCastingMode)castShadows.enumValueIndex;
                        ((Volume)o).CreateChunks();
                    }
                }

                receiveShadows.boolValue = EditorGUILayout.ToggleLeft(new GUIContent(" Receive Shadows"),
                                                                      receiveShadows.boolValue);
                if (receiveShadows.boolValue != voxelObject.ReceiveShadows)
                {
                    foreach (var o in serializedObject.targetObjects)
                    {
                        ((Volume)o).ReceiveShadows = receiveShadows.boolValue;
                        ((Volume)o).CreateChunks();
                    }
                }
            }



            EditorGUILayout.Space();
            EditorGUILayout.Space();
            if (GUILayout.Button(new GUIContent("Mesh-Only Copy", "Create a copy of this Volume with mesh(es) only")))
            {
                foreach (var target in serializedObject.targetObjects)
                {
                    GameObject bake = ((Volume)Instantiate(target)).gameObject;
                    bake.GetComponent <Volume>().AssetGuid = Guid.NewGuid().ToString();
                    foreach (Frame f in bake.GetComponent <Volume>().Frames)
                    {
                        f.AssetGuid = Guid.NewGuid().ToString();
                    }
                    bake.GetComponent <Volume>().CreateChunks();
                    bake.tag  = "Untagged";
                    bake.name = target.name + " (Copy)";
                    DestroyImmediate(bake.GetComponent <Volume>());
                    DestroyImmediate(bake.transform.FindChild("Hitbox").gameObject);
                    for (int i = 0; i < bake.transform.childCount; i++)
                    {
                        GameObject o = bake.transform.GetChild(i).gameObject;
                        if (o.GetComponent <Frame>() != null)
                        {
                            DestroyImmediate(o.GetComponent <Frame>());
                            for (int c = 0; c < o.transform.FindChild("Chunks").childCount; c++)
                            {
                                GameObject chunk = o.transform.FindChild("Chunks").GetChild(c).gameObject;
                                if (chunk.GetComponent <Chunk>() != null)
                                {
                                    DestroyImmediate(chunk.GetComponent <Chunk>());
                                }
                            }
                        }
                    }
                }
            }

            EditorGUILayout.Space();
            if (GUILayout.Button(new GUIContent("Refresh Chunks", "Regenerates all chunk meshes for all frames")))
            {
                foreach (var o in serializedObject.targetObjects)
                {
                    ((Volume)o).CreateChunks();
                    ((Volume)o).SaveForSerialize();
                }
            }

            if (voxelObject.ImportedFrom != Importer.None && !string.IsNullOrEmpty(voxelObject.ImportedFile) &&
                serializedObject.targetObjects.Length < 2 && !voxelObject.IsEnabledForEditing)
            {
                EditorGUILayout.Space();
                if (
                    GUILayout.Button(
                        new GUIContent(
                            voxelObject.ImportedFrom == Importer.Magica
                                ? "Re-import from MagicaVoxel"
                                : "Re-import from Image",
                            voxelObject.ImportedFrom == Importer.Magica
                                ? "Re-import from original .VOX file"
                                : "Re-import from original image file")))
                {
                    if (UnityEditor.EditorUtility.DisplayDialog("Warning!",
                                                                "Re-importing will overwrite any changes made since original import. This cannot be undone!",
                                                                "OK", "Cancel"))
                    {
                        foreach (var o in serializedObject.targetObjects)
                        {
                            switch (voxelObject.ImportedFrom)
                            {
                            case Importer.Magica:
                                MagicaVoxelImporter.MagicaVoxelImport((Volume)o);
                                break;

                            case Importer.Image:
                                ImageImporter.ImageImport((Volume)o);
                                break;
                            }
                        }
                    }
                }
            }

            EditorGUILayout.Space();
            if (GUILayout.Button(new GUIContent("New Mesh Asset Instance", "Creates a new set of mesh assets for this volume. Use if you have copy+pasted or duplicated the volume and want the mesh to be separate from the original at edit-time.")))
            {
                foreach (var o in serializedObject.targetObjects)
                {
                    ((Volume)o).SaveChunkMeshes(true);
                }
            }

            if (Application.isPlaying)
            {
                EditorGUILayout.Space();
                if (GUILayout.Button(new GUIContent("Rebuild Volume", "Reset any voxels that have been destroyed")))
                {
                    foreach (var o in serializedObject.targetObjects)
                    {
                        ((Volume)o).Rebuild();
                    }
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
コード例 #8
0
        //For generic automatic editors. Passing a MemberInfo will also check for attributes
        public static object GenericField(string name, object value, Type t, MemberInfo member = null, object instance = null)
        {
            if (t == null)
            {
                GUILayout.Label("NO TYPE PROVIDED!");
                return(value);
            }

            if (member != null)
            {
                //Hide class?
                if (t.GetCustomAttributes(typeof(HideInInspector), true).FirstOrDefault() != null)
                {
                    return(value);
                }

                //Hide field?
                if (member.GetCustomAttributes(typeof(HideInInspector), true).FirstOrDefault() != null)
                {
                    return(value);
                }

                //Is required?
                if (member.GetCustomAttributes(typeof(RequiredFieldAttribute), true).FirstOrDefault() != null)
                {
                    if ((value == null || value.Equals(null)) ||
                        (t == typeof(string) && string.IsNullOrEmpty((string)value)) ||
                        (typeof(BBParameter).IsAssignableFrom(t) && (value as BBParameter).isNull))
                    {
                        GUI.backgroundColor = lightRed;
                    }
                }
            }


            name = name.SplitCamelCase();


            if (member != null)
            {
                var nameAtt = member.GetCustomAttributes(typeof(NameAttribute), true).FirstOrDefault() as NameAttribute;
                if (nameAtt != null)
                {
                    name = nameAtt.name;
                }

                if (instance != null)
                {
                    var showAtt = member.GetCustomAttributes(typeof(ShowIfAttribute), true).FirstOrDefault() as ShowIfAttribute;
                    if (showAtt != null)
                    {
                        var targetField = instance.GetType().GetField(showAtt.fieldName);
                        if (targetField == null || targetField.FieldType != typeof(bool))
                        {
                            GUILayout.Label(string.Format("[ShowIf] Error: bool \"{0}\" does not exist.", showAtt.fieldName));
                        }
                        else
                        {
                            if ((bool)targetField.GetValue(instance) != showAtt.show)
                            {
                                return(value);
                            }
                        }
                    }
                }
            }



            //Before everything check BBParameter
            if (typeof(BBParameter).IsAssignableFrom(t))
            {
                return(BBParameterField(name, (BBParameter)value, false, member));
            }

            //Then check UnityObjects
            if (typeof(UnityObject).IsAssignableFrom(t))
            {
                if (t == typeof(Component) && (Component)value != null)
                {
                    return(ComponentField(name, (Component)value, typeof(Component)));
                }
                return(EditorGUILayout.ObjectField(name, (UnityObject)value, t, (typeof(Component).IsAssignableFrom(t) || t == typeof(GameObject) || t == typeof(UnityObject))));
            }

            //Force UnityObject field?
            if (member != null && member.GetCustomAttributes(typeof(ForceObjectFieldAttribute), true).FirstOrDefault() != null)
            {
                return(EditorGUILayout.ObjectField(name, value as UnityObject, t, true));
            }

            //Restricted popup values?
            if (member != null)
            {
                var popAtt = member.GetCustomAttributes(typeof(PopupFieldAttribute), true).FirstOrDefault() as PopupFieldAttribute;
                if (popAtt != null)
                {
                    return(Popup <object>(name, value, popAtt.values.ToList(), false));
                }
            }


            //Check Type of Type
            if (t == typeof(Type))
            {
                return(Popup <Type>(name, (Type)value, UserTypePrefs.GetPreferedTypesList(typeof(object), false)));
            }

            //Check abstract
            if ((value != null && value.GetType().IsAbstract) || (value == null && t.IsAbstract))
            {
                EditorGUILayout.LabelField(name, string.Format("Abstract ({0})", t.FriendlyName()));
                return(value);
            }

            //Create instance for some types
            if (value == null && !t.IsAbstract && !t.IsInterface && (t.IsValueType || t.GetConstructor(Type.EmptyTypes) != null || t.IsArray))
            {
                if (t.IsArray)
                {
                    value = Array.CreateInstance(t.GetElementType(), 0);
                }
                else
                {
                    value = Activator.CreateInstance(t);
                }
            }



            //Check the rest
            //..............
            if (t == typeof(string))
            {
                if (member != null)
                {
                    if (member.GetCustomAttributes(typeof(TagFieldAttribute), true).FirstOrDefault() != null)
                    {
                        return(EditorGUILayout.TagField(name, (string)value));
                    }
                    var areaAtt = member.GetCustomAttributes(typeof(TextAreaFieldAttribute), true).FirstOrDefault() as TextAreaFieldAttribute;
                    if (areaAtt != null)
                    {
                        GUILayout.Label(name);
                        var areaStyle = new GUIStyle(GUI.skin.GetStyle("TextArea"));
                        areaStyle.wordWrap = true;
                        var s = EditorGUILayout.TextArea((string)value, areaStyle, GUILayout.Height(areaAtt.height));
                        return(s);
                    }
                }

                return(EditorGUILayout.TextField(name, (string)value));
            }

            if (t == typeof(bool))
            {
                return(EditorGUILayout.Toggle(name, (bool)value));
            }

            if (t == typeof(int))
            {
                if (member != null)
                {
                    var sField = member.GetCustomAttributes(typeof(SliderFieldAttribute), true).FirstOrDefault() as SliderFieldAttribute;
                    if (sField != null)
                    {
                        return((int)EditorGUILayout.Slider(name, (int)value, (int)sField.left, (int)sField.right));
                    }
                    if (member.GetCustomAttributes(typeof(LayerFieldAttribute), true).FirstOrDefault() != null)
                    {
                        return(EditorGUILayout.LayerField(name, (int)value));
                    }
                }

                return(EditorGUILayout.IntField(name, (int)value));
            }

            if (t == typeof(float))
            {
                if (member != null)
                {
                    var sField = member.GetCustomAttributes(typeof(SliderFieldAttribute), true).FirstOrDefault() as SliderFieldAttribute;
                    if (sField != null)
                    {
                        return(EditorGUILayout.Slider(name, (float)value, sField.left, sField.right));
                    }
                }
                return(EditorGUILayout.FloatField(name, (float)value));
            }

            if (t == typeof(Vector2))
            {
                return(EditorGUILayout.Vector2Field(name, (Vector2)value));
            }

            if (t == typeof(Vector3))
            {
                return(EditorGUILayout.Vector3Field(name, (Vector3)value));
            }

            if (t == typeof(Vector4))
            {
                return(EditorGUILayout.Vector4Field(name, (Vector4)value));
            }

            if (t == typeof(Quaternion))
            {
                var quat = (Quaternion)value;
                var vec4 = new Vector4(quat.x, quat.y, quat.z, quat.w);
                vec4 = EditorGUILayout.Vector4Field(name, vec4);
                return(new Quaternion(vec4.x, vec4.y, vec4.z, vec4.w));
            }

            if (t == typeof(Color))
            {
                return(EditorGUILayout.ColorField(name, (Color)value));
            }

            if (t == typeof(Rect))
            {
                return(EditorGUILayout.RectField(name, (Rect)value));
            }

            if (t == typeof(AnimationCurve))
            {
                return(EditorGUILayout.CurveField(name, (AnimationCurve)value));
            }

            if (t == typeof(Bounds))
            {
                return(EditorGUILayout.BoundsField(name, (Bounds)value));
            }

            if (t == typeof(LayerMask))
            {
                return(LayerMaskField(name, (LayerMask)value));
            }

            if (t.IsSubclassOf(typeof(System.Enum)))
            {
                return(EditorGUILayout.EnumPopup(name, (System.Enum)value));
            }

            if (typeof(IList).IsAssignableFrom(t))
            {
                return(ListEditor(name, (IList)value, t));
            }

            if (typeof(IDictionary).IsAssignableFrom(t))
            {
                return(DictionaryEditor(name, (IDictionary)value, t));
            }


            //show nested class members recursively
            if (value != null && !t.IsEnum && !t.IsInterface)
            {
                GUILayout.BeginVertical();
                EditorGUILayout.LabelField(name, t.FriendlyName());
                EditorGUI.indentLevel++;
                foreach (var field in value.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public))
                {
                    field.SetValue(value, GenericField(field.Name, field.GetValue(value), field.FieldType, field));
                }
                EditorGUI.indentLevel--;
                GUILayout.EndVertical();
            }
            else
            {
                EditorGUILayout.LabelField(name, string.Format("({0})", t.FriendlyName()));
            }

            return(value);
        }
コード例 #9
0
        private void DrawAdvancedSearch(ProDrawCallOptimizerMenu window)
        {
            GUILayout.BeginArea(new Rect(5, 40, window.position.width - 10, 70));
            EditorGUILayout.BeginVertical();
            GUILayout.Label("Advanced search:");
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(35);
            EditorGUILayout.BeginVertical();
            GUILayout.Space(5);
            selectedLayer = EditorGUILayout.LayerField("Select Objects By Layer:", selectedLayer);
            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Select", GUILayout.Width(60)))
            {
                List <GameObject> selectedObjects = new List <GameObject>();
                GameObject[]      allObjs         = GameObject.FindObjectsOfType(typeof(GameObject)) as GameObject[];
                foreach (GameObject g in allObjs)
                {
                    if (g.layer == selectedLayer)
                    {
                        selectedObjects.Add(g);
                    }
                }
                Selection.objects = selectedObjects.ToArray();
                consoleStatus     = "Selected " + Selection.objects.Length + " Game Objects with layer: '" + LayerMask.LayerToName(selectedLayer) + "'";
            }
            if (GUILayout.Button("Add Selected", GUILayout.Width(100)))
            {
                ObjectsGUI.Instance.FillArrayWithSelectedObjects(Selection.gameObjects);
                consoleStatus = "Added " + Selection.gameObjects.Length + " Game objects to be optimized.";
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(35);
            EditorGUILayout.BeginVertical();
            GUILayout.Space(5);
            selectedTag = EditorGUILayout.TagField("Select Objects By Tag:", selectedTag);
            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Select", GUILayout.Width(60)))
            {
                List <GameObject> selectedObjects = new List <GameObject>();
                if (selectedTag == "Untagged")                 //when  there are untagged objs the selection has to be done manually
                {
                    GameObject[] allObjs = GameObject.FindObjectsOfType(typeof(GameObject)) as GameObject[];
                    foreach (GameObject g in allObjs)
                    {
                        if (g.tag == "Untagged")
                        {
                            selectedObjects.Add(g);
                        }
                    }
                    Selection.objects = selectedObjects.ToArray();
                }
                else
                {
                    Selection.objects = GameObject.FindGameObjectsWithTag(selectedTag);
                }
                consoleStatus = "Selected " + Selection.objects.Length + " Game Objects with tag: '" + selectedTag + "'";
            }
            if (GUILayout.Button("Add Selected", GUILayout.Width(100)))
            {
                ObjectsGUI.Instance.FillArrayWithSelectedObjects(Selection.gameObjects);
                consoleStatus = "Added " + Selection.gameObjects.Length + " Game objects to be optimized.";
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
            GUILayout.EndArea();
        }
コード例 #10
0
    private void OnGUI()
    {
        float wFix = 0.5f;

        scroll_position = GUILayout.BeginScrollView(scroll_position, GUILayout.Width(Screen.width), GUILayout.Height(Screen.height - 20));

        GUILayout.Label("Various tools to add or remove components from every bone.", EditorStyles.wordWrappedMiniLabel);

        // show targets
        GUILayout.Label("Target Objects:", EditorStyles.boldLabel);
        {
            if (objects.Count > 0)
            {
                for (int i = 0; i < objects.Count; ++i)
                {
                    GUILayout.BeginHorizontal();
                    objects[i] = EditorGUILayout.ObjectField(objects[i], typeof(GameObject), true, GUILayout.Width(Screen.width * wFix)) as GameObject;
                    if (prefixes[i] != null)
                    {
                        prefixes[i] = EditorGUILayout.TextField(prefixes[i]);
                    }
                    GUILayout.EndHorizontal();

                    // set null
                    if (objects[i] == null)
                    {
                        objects.RemoveAt(i);
                        prefixes.RemoveAt(i);
                    }
                }

                if (GUILayout.Button("Clear"))
                {
                    objects.Clear();
                }
            }
            else
            {
                GUILayout.Label("Select objects with Component \"NeuronAnimatorDriver\" or \"NeuronTransformsDriver\".", EditorStyles.wordWrappedMiniLabel);
            }
        }

        // show tools
        if (objects.Count > 0)
        {
            // collider tools
            GUILayout.Label("Colliders Settings:", EditorStyles.boldLabel);
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Bone Collider Layer: ");
                bone_collider_layer = EditorGUILayout.LayerField(bone_collider_layer, GUILayout.Width(Screen.width * wFix));
                GUILayout.EndHorizontal();

                if (GUILayout.Button("Add Colliders") && CheckSelectedObjects())
                {
                    for (int i = 0; i < objects.Count; ++i)
                    {
                        GameObject obj    = objects[i];
                        string     prefix = prefixes[i];

                        if (obj != null)
                        {
                            if (prefix == null)
                            {
                                Neuron.BoneColliders.AddSkeletonColliders(obj.GetComponent <Animator>(), collider_template_path, collider_template_path2, bone_collider_layer);
                            }
                            else
                            {
                                Neuron.BoneColliders.AddSkeletonColliders(obj.transform, prefix, collider_template_path, collider_template_path2, bone_collider_layer);
                            }
                        }
                    }
                }

                if (GUILayout.Button("Remove Colliders") && CheckSelectedObjects())
                {
                    for (int i = 0; i < objects.Count; ++i)
                    {
                        GameObject obj    = objects[i];
                        string     prefix = prefixes[i];

                        if (obj != null)
                        {
                            if (prefix == null)
                            {
                                Neuron.BoneColliders.RemoveSkeletonColliders(obj.GetComponent <Animator>());
                            }
                            else
                            {
                                Neuron.BoneColliders.RemoveSkeletonColliders(obj.transform, prefix);
                            }
                        }
                    }
                }

                GUILayout.BeginHorizontal();
                GUILayout.Label("Bone Collider Color: ");
                bone_collider_color = EditorGUILayout.ColorField(bone_collider_color, GUILayout.Width(Screen.width * wFix));
                GUILayout.EndHorizontal();

                if (GUILayout.Button("Show Colliders") && CheckSelectedObjects())
                {
                    for (int i = 0; i < objects.Count; ++i)
                    {
                        GameObject obj    = objects[i];
                        string     prefix = prefixes[i];

                        if (obj != null)
                        {
                            if (prefix == null)
                            {
                                Neuron.BoneColliders.AddSkeletonColliderRenderers(obj.GetComponent <Animator>(), bone_collider_color);
                            }
                            else
                            {
                                Neuron.BoneColliders.AddSkeletonColliderRenderers(obj.transform, prefix, bone_collider_color);
                            }
                        }
                    }
                }

                if (GUILayout.Button("Hide Colliders") && CheckSelectedObjects())
                {
                    for (int i = 0; i < objects.Count; ++i)
                    {
                        GameObject obj    = objects[i];
                        string     prefix = prefixes[i];

                        if (obj != null)
                        {
                            if (prefix == null)
                            {
                                Neuron.BoneColliders.RemoveSkeletonColliderRenderers(obj.GetComponent <Animator>());
                            }
                            else
                            {
                                Neuron.BoneColliders.RemoveSkeletonColliderRenderers(obj.transform, prefix);
                            }
                        }
                    }
                }
            }

            // rigidbody tools
            GUILayout.Label("Rigidbodies Settings:", EditorStyles.boldLabel);
            {
                if (GUILayout.Button("Add Rigidbodies") && CheckSelectedObjects())
                {
                    for (int i = 0; i < objects.Count; ++i)
                    {
                        GameObject obj    = objects[i];
                        string     prefix = prefixes[i];

                        if (obj != null)
                        {
                            if (prefix == null)
                            {
                                Neuron.BoneRigidbodies.AddSkeletonRigidBodies(obj.GetComponent <Animator>());
                            }
                            else
                            {
                                Neuron.BoneRigidbodies.AddSkeletonRigidBodies(obj.transform, prefix);
                            }
                        }
                    }
                }

                if (GUILayout.Button("Remove Rigidbodies") && CheckSelectedObjects())
                {
                    for (int i = 0; i < objects.Count; ++i)
                    {
                        GameObject obj    = objects[i];
                        string     prefix = prefixes[i];

                        if (obj != null)
                        {
                            if (prefix == null)
                            {
                                Neuron.BoneRigidbodies.RemoveSkeletonRigidBodies(obj.GetComponent <Animator>());
                            }
                            else
                            {
                                Neuron.BoneRigidbodies.RemoveSkeletonRigidBodies(obj.transform, prefix);
                            }
                        }
                    }
                }
            }

            // bone line tools
            GUILayout.Label("BoneLine Settings:", EditorStyles.boldLabel);
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Bone Line Color: ");
                bone_line_color = EditorGUILayout.ColorField(bone_line_color, GUILayout.Width(Screen.width * wFix));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Bone Line Parent Width: ");
                bone_line_parent_width = EditorGUILayout.Slider(bone_line_parent_width, 0.001f, 0.1f, GUILayout.Width(Screen.width * wFix));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Bone Line Child Width: ");
                bone_line_child_width = EditorGUILayout.Slider(bone_line_child_width, 0.001f, 0.1f, GUILayout.Width(Screen.width * wFix));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Bone Line Render Order: ");
                bone_line_render_order = int.Parse(EditorGUILayout.TextField(bone_line_render_order.ToString(), GUILayout.Width(Screen.width * wFix)));
                GUILayout.EndHorizontal();

                if (GUILayout.Button("Add BoneLines") && CheckSelectedObjects())
                {
                    for (int i = 0; i < objects.Count; ++i)
                    {
                        GameObject obj    = objects[i];
                        string     prefix = prefixes[i];

                        if (obj != null)
                        {
                            if (prefix == null)
                            {
                                Neuron.BoneLines.AddSkeletonBoneLines(obj.GetComponent <Animator>(), bone_line_color, 10, bone_line_parent_width, bone_line_child_width);
                            }
                            else
                            {
                                Neuron.BoneLines.AddSkeletonBoneLines(obj.transform, prefix, bone_line_color, 10, bone_line_parent_width, bone_line_child_width);
                            }
                        }
                    }
                }

                if (GUILayout.Button("Remove BoneLines") && CheckSelectedObjects())
                {
                    for (int i = 0; i < objects.Count; ++i)
                    {
                        GameObject obj    = objects[i];
                        string     prefix = prefixes[i];

                        if (obj != null)
                        {
                            if (prefix == null)
                            {
                                Neuron.BoneLines.RemoveSkeletonBoneLines(obj.GetComponent <Animator>());
                            }
                            else
                            {
                                Neuron.BoneLines.RemoveSkeletonBoneLines(obj.transform, prefix);
                            }
                        }
                    }
                }
            }
        }

        GUILayout.EndScrollView();
    }
コード例 #11
0
        public override void OnInspectorGUI()
        {
            foreach (var categoryProperties in _resourceManager.CategoryProperties)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(FoldoutSpace);
                var foldout = EditorGUILayout.Foldout(
                    _resourceManager.CategoryFoldouts[categoryProperties.Category],
                    categoryProperties.Category);
                GUILayout.EndHorizontal();

                _resourceManager.CategoryFoldouts[categoryProperties.Category] = foldout;
                if (foldout)
                {
                    foreach (var property in categoryProperties.Properties)
                    {
                        var propertyType = property.Type;

                        GUILayout.BeginHorizontal();
                        GUILayout.Space(FoldoutSpace);
                        GUILayout.Label(new GUIContent(property.DisplayName, property.Description));
                        GUILayout.FlexibleSpace();

                        switch (property.PropertyKind)
                        {
                        case PropertyKind.Undefined:
                            if (propertyType == typeof(Color))
                            {
                                property.SetValue(EditorGUILayout.ColorField(property.GetValue <Color>()));
                            }
                            else if (propertyType == typeof(float))
                            {
                                property.SetValue(
                                    EditorGUILayout.DelayedFloatField(
                                        property.GetValue <float>()));
                            }
                            else if (propertyType == typeof(string))
                            {
                                property.SetValue(
                                    EditorGUILayout.DelayedTextField(
                                        property.GetValue <string>()));
                            }
                            else if (propertyType == typeof(int))
                            {
                                property.SetValue(EditorGUILayout.DelayedIntField(property.GetValue <int>()));
                            }
                            else if (propertyType == typeof(long))
                            {
                                property.SetValue(EditorGUILayout.LongField(property.GetValue <long>()));
                            }
                            else if (propertyType == typeof(double))
                            {
                                property.SetValue(EditorGUILayout.DoubleField(property.GetValue <double>()));
                            }
                            else if (propertyType == typeof(bool))
                            {
                                property.SetValue(EditorGUILayout.Toggle(
                                                      GUIContent.none,
                                                      property.GetValue <bool>()));
                            }
                            else if (propertyType == typeof(Vector2))
                            {
                                property.SetValue(EditorGUILayout.Vector2Field(GUIContent.none,
                                                                               property.GetValue <Vector2>()));
                            }
                            else if (propertyType == typeof(Vector3))
                            {
                                property.SetValue(EditorGUILayout.Vector3Field(
                                                      GUIContent.none,
                                                      property.GetValue <Vector3>()));
                            }
                            else if (propertyType == typeof(Bounds))
                            {
                                property.SetValue(EditorGUILayout.BoundsField(property.GetValue <Bounds>()));
                            }
                            else if (propertyType == typeof(Rect))
                            {
                                property.SetValue(EditorGUILayout.RectField(property.GetValue <Rect>()));
                            }
                            else if (propertyType.IsEnum)
                            {
                                var flagsAttribute = propertyType.GetCustomAttributes(typeof(FlagsAttribute), false)
                                                     .Cast <FlagsAttribute>()
                                                     .FirstOrDefault();

                                property.SetValue(flagsAttribute != null
                                        ? EditorGUILayout.EnumMaskField(property.GetValue <Enum>())
                                        : EditorGUILayout.EnumPopup(property.GetValue <Enum>()));
                            }
                            else if (typeof(UnityEngine.Object).IsAssignableFrom(propertyType))
                            {
                                property.SetValue(EditorGUILayout.ObjectField(
                                                      property.GetValue <UnityEngine.Object>(),
                                                      propertyType,
                                                      true));
                            }
                            break;

                        case PropertyKind.Tag:
                            property.SetValue(EditorGUILayout.TagField(property.GetValue <string>()));
                            break;

                        case PropertyKind.Layer:
                            property.SetValue(EditorGUILayout.LayerField(property.GetValue <int>()));
                            break;

                        case PropertyKind.Passwort:
                            property.SetValue(EditorGUILayout.PasswordField(property.GetValue <string>()));
                            break;

                        default:
                            throw new NotSupportedException(string.Format(
                                                                "The property kind '{0}' is not supported.",
                                                                property.PropertyKind));
                        }

                        GUILayout.EndHorizontal();
                    }
                }
            }
        }
コード例 #12
0
        private static void drawProperty(PropertyField field, GUILayoutOption[] options)
        {
            switch (field.Type)
            {
            case SerializedPropertyType.Integer:
            {
                field.Value = EditorGUILayout.IntField(field.Name, (int)field.Value, options);
                break;
            }

            case SerializedPropertyType.Float:
            {
                field.Value = EditorGUILayout.FloatField(field.Name, (float)field.Value, options);
                break;
            }

            case SerializedPropertyType.Boolean:
            {
                field.Value = EditorGUILayout.Toggle(field.Name, (bool)field.Value, options);
                break;
            }

            case SerializedPropertyType.String:
            {
                field.Value = EditorGUILayout.TextField(field.Name, (string)field.Value, options);
                break;
            }

            case SerializedPropertyType.Color:
            {
                field.Value = EditorGUILayout.ColorField(field.Name, (Color)field.Value, options);
                break;
            }

            case SerializedPropertyType.ObjectReference:
            {
                field.Value = EditorGUILayout.ObjectField(field.Name, (UnityEngine.Object)field.Value,
                                                          field.GetType(), true, options);
                break;
            }

            case SerializedPropertyType.LayerMask:
            {
                field.Value = EditorGUILayout.LayerField(field.Name, (LayerMask)field.Value, options);
                break;
            }

            case SerializedPropertyType.Enum:
            {
                field.Value = EditorGUILayout.EnumPopup(field.Name, (Enum)field.Value, options);
                break;
            }

            case SerializedPropertyType.Vector2:
            {
                field.Value = EditorGUILayout.Vector2Field(field.Name, (Vector2)field.Value, options);
                break;
            }

            case SerializedPropertyType.Vector3:
            {
                field.Value = EditorGUILayout.Vector3Field(field.Name, (Vector3)field.Value, options);
                break;
            }

            case SerializedPropertyType.Vector4:
            {
                field.Value = EditorGUILayout.Vector4Field(field.Name, (Vector4)field.Value, options);
                break;
            }

            case SerializedPropertyType.Rect:
            {
                field.Value = EditorGUILayout.RectField(field.Name, (Rect)field.Value, options);
                break;
            }

            case SerializedPropertyType.AnimationCurve:
            {
                field.Value = EditorGUILayout.CurveField(field.Name, (AnimationCurve)field.Value, options);
                break;
            }

            case SerializedPropertyType.Bounds:
            {
                field.Value = EditorGUILayout.BoundsField(field.Name, (Bounds)field.Value, options);
                break;
            }

            case SerializedPropertyType.Gradient:
            {
                field.Value = GUIGradientField.GradientField(field.Name, (Gradient)field.Value, options);
                break;
            }

            case SerializedPropertyType.Quaternion:
            {
                Quaternion quat = (Quaternion)field.Value;
                field.Value = EditorGUILayout.Vector4Field(field.Name, new Vector4(quat.x, quat.y, quat.z, quat.w), options);
                break;
            }
            }
        }
コード例 #13
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            EditorGUILayout.LabelField(string.Format("Current Plugin Version: {0}", Version.Current), EditorStyles.miniBoldLabel);

            Header("Beam Geometry");
            EditorGUI.BeginChangeCheck();
            geometryLayerID.intValue = EditorGUILayout.LayerField(new GUIContent("Layer", "The layer the GameObjects holding the procedural cone meshes are created on"), geometryLayerID.intValue);
            if (EditorGUI.EndChangeCheck())
            {
            }
            EditorGUILayout.PropertyField(beamShader, new GUIContent("Shader", "Main shader applied to the cone beam geometry"));
            EditorGUILayout.PropertyField(SharedMesh, new GUIContent("SharedMesh", "共享模型"));

            Header("Global 3D Noise");
            EditorGUILayout.PropertyField(globalNoiseScale, new GUIContent("Scale", "Global 3D Noise texture scaling: higher scale make the noise more visible, but potentially less realistic"));
            EditorGUILayout.PropertyField(globalNoiseVelocity, new GUIContent("Velocity", "Global World Space direction and speed of the noise scrolling, simulating the fog/smoke movement"));

            Header("3D Noise Texture Data");
            bool reloadNoise = false;

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(noise3DData, new GUIContent("Binary file", "Binary file holding the 3D Noise texture data (a 3D array). Must be exactly Size * Size * Size bytes long."));
            int newSizeValue = EditorGUILayout.IntField(new GUIContent("Data dimension", "Size (of one dimension) of the 3D Noise data. Must be power of 2. So if the binary file holds a 32x32x32 texture, this value must be 32.")
                                                        , noise3DSize.intValue);

            noise3DSize.intValue = Mathf.Max(2, Mathf.NextPowerOfTwo(newSizeValue));
            if (EditorGUI.EndChangeCheck())
            {
                reloadNoise = true;
            }

            if (Noise3D.isSupported && !Noise3D.isProperlyLoaded)
            {
                EditorGUILayout.HelpBox("Fail to load 3D noise texture", MessageType.Error);
            }

            Header("Volumetric Dust Particles");
            EditorGUILayout.PropertyField(dustParticlesPrefab, new GUIContent("Prefab", "ParticleSystem prefab instantiated for the Volumetric Dust Particles feature (Unity 5.5 or above)"));

            Header("Level 1");
            EditorGUILayout.PropertyField(L1_Texture, new GUIContent("Level 1 LightTexture"));
            EditorGUILayout.PropertyField(L1_Noise, new GUIContent("Level 1 Noise"));
            EditorGUILayout.PropertyField(L1_beamShader, new GUIContent("Level 1 Shader"));


            EditorGUILayout.Space();
            if (GUILayout.Button(new GUIContent("Default values", "Reset properties to their default values."), EditorStyles.miniButton))
            {
                UnityEditor.Undo.RecordObject(target, "Reset Config Properties");
                (target as Config).Reset();
            }

            serializedObject.ApplyModifiedProperties();

            if (reloadNoise)
            {
                Noise3D._EditorForceReloadData(); // Should be called AFTER ApplyModifiedProperties so the Config instance has the proper values when reloading data
            }
        }
コード例 #14
0
    override public void OnInspectorGUI()
    {
        serializedObject.Update();

        colourGradient = serializedObject.FindProperty("lineColour");

        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Appearance", EditorStyles.boldLabel);
        lineOptionsInt = GUILayout.Toolbar(lineOptionsInt, lineOptions, EditorStyles.miniButton, GUILayout.Height(18));

        EditorGUILayout.Space();
        pp.noOfTrajectoryPoints = EditorGUILayout.IntField(new GUIContent("No. of Points", "The number of points you want in your trajectory path (more equals smoother path)"), pp.noOfTrajectoryPoints);

        //specific properties for dotted line
        if (lineOptionsInt == 1)
        {
            pp.enableSolidLine = false;

            pp.trajectoryPointPrefab = (GameObject)EditorGUILayout.ObjectField(new GUIContent("Trajectory Prefab", "The prefab you want to clone along your trajectory"), pp.trajectoryPointPrefab, typeof(GameObject), true);
        }

        //specific properties for solid line
        if (lineOptionsInt == 0)
        {
            pp.enableSolidLine = true;
            pp.isAI            = EditorGUILayout.Toggle(new GUIContent("Is AI", "Toggle AI"), pp.isAI);
            pp.cornerVerts     = EditorGUILayout.IntField(new GUIContent("Corner Roundness", "Increase the number of verts at the corners of your trajectory"), pp.cornerVerts);
            pp.endVerts        = EditorGUILayout.IntField(new GUIContent("End Roundness", "Increase roundness of the ends of your trajectory"), pp.endVerts);
            pp.widthCurve      = EditorGUILayout.CurveField(new GUIContent("Width Curve", "Define the width of your trajectory"), pp.widthCurve, Color.red, new Rect(0, 0, 1, 1));
            EditorGUILayout.PropertyField(colourGradient, new GUIContent("Colour", "Define the colour gradient of your trajectory"));

            pp.lineMaterial = (Material)EditorGUILayout.ObjectField(new GUIContent("Material", "Apply a material to your trajectory"), pp.lineMaterial, typeof(Material), true);
            pp.textureMode  = EditorGUILayout.Toggle(new GUIContent("Tiled", "Tile your material along your trajectory"), pp.textureMode == LineTextureMode.Tile) ? LineTextureMode.Tile : LineTextureMode.Stretch;

            if (pp.textureMode == LineTextureMode.Tile)
            {
                EditorGUILayout.HelpBox("Remember to use the Pixul shader located in the Shaders folder", MessageType.Info);
                pp.tileAmount = EditorGUILayout.Slider(new GUIContent("Tile Amount", "Set the tiling amount for your trajectory material"), pp.tileAmount, 0.1f, 10.0f);
            }
        }

        pp.destroyAfterFire = EditorGUILayout.Toggle(new GUIContent("Destroy after firing", "Destroy your trajectory after firing"), pp.destroyAfterFire);
        if (pp.destroyAfterFire)
        {
            pp.destroyDelay = EditorGUILayout.FloatField(new GUIContent("Destroy Delay", "Time to delay the destroy (seconds)"), pp.destroyDelay);
        }

        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Physics Properties", EditorStyles.boldLabel);
        pp.m_gravity = EditorGUILayout.Vector2Field(new GUIContent("Gravity", "Controls the effect on the physics object during movement"), pp.m_gravity);
        pp.m_power   = EditorGUILayout.FloatField(new GUIContent("Power", "Factor applied to the initial velocity"), pp.m_power);

        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Collision Properties", EditorStyles.boldLabel);
        pp.m_damping = EditorGUILayout.FloatField(new GUIContent("Damping", "Velocity will be factored by this if a collision occurs. Can be overridden using the collision properties script on the colliding object"), pp.m_damping);

        pp.m_ObstaclesLayerMask = EditorGUILayout.LayerField(new GUIContent("Obstacles Layer", "Layer that contains all the objects you wish the physics object to collide with"), pp.m_ObstaclesLayerMask);

        if (GUI.changed)
        {
            EditorUtility.SetDirty(pp);
        }

        // Apply changes to the serializedProperty - always do this at the end of OnInspectorGUI.
        serializedObject.ApplyModifiedProperties();
    }
コード例 #15
0
    //draw custom editor window GUI
    void OnGUI()
    {
        //display label and object field for projectile model slot
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Projectile Model:");
        projectileModel = (GameObject)EditorGUILayout.ObjectField(projectileModel, typeof(GameObject), false);
        EditorGUILayout.EndHorizontal();

        //display label and enum list for collider type
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Collider Type:");
        colliderType = (ColliderType)EditorGUILayout.EnumPopup(colliderType);
        EditorGUILayout.EndHorizontal();

        //display label and layer field for projectile layer
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Projectile Layer:");
        layer = EditorGUILayout.LayerField(layer);
        EditorGUILayout.EndHorizontal();

        //display label and checkbox for Projectile component
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Attach Projectile:");
        attachProjectile = EditorGUILayout.Toggle(attachProjectile);
        EditorGUILayout.EndHorizontal();

        //display label and checkbox for Rigidbody component
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Attach Rigidbody:");
        attachRigidbody = EditorGUILayout.Toggle(attachRigidbody);
        EditorGUILayout.EndHorizontal();

        //display info box below all settings
        EditorGUILayout.Space();
        EditorGUILayout.HelpBox("By clicking on 'Apply!' all chosen components are added and a prefab will be created next to your projectile model.", MessageType.Info);
        EditorGUILayout.Space();

        //apply button
        if (GUILayout.Button("Apply!"))
        {
            //cancel further execution if no tower model is set
            if (projectileModel == null)
            {
                Debug.LogWarning("No projectile model chosen. Aborting Projectile Setup execution.");
                return;
            }

            //get model's asset path in this project to place the new prefab next to it
            string assetPath = AssetDatabase.GetAssetPath(projectileModel.GetInstanceID());
            //e.g. assetPath = "Assets/Models/model.fbx
            //split folder structure for renaming the existing model name as prefab
            string[] folders = assetPath.Split('/');
            //e.g. folders[0] = "Assets", folders[1] = "Models", folders[2] = "model.fbx"
            //then we replace the last part, the model name in folders[2], with the new prefab name
            assetPath = assetPath.Replace(folders[folders.Length - 1], projectileModel.name + ".prefab");
            //new asset path: "Assets/Models/model.prefab"


            //instantiate, convert and setup model to new prefab
            ProcessModel();

            //if Projectile checkbox is checked
            if (attachProjectile)
            {
                //attach Projectile component
                projectileModel.AddComponent <Projectile>();
            }

            //if Rigidbody checkbox is checked, add component
            if (attachRigidbody)
            {
                //attach and store rigidbody component
                Rigidbody rigid = projectileModel.AddComponent <Rigidbody>();
                //make rigidbody kinematic
                rigid.isKinematic = true;
                //disable gravity
                rigid.useGravity = false;
            }

            //initialize prefab gameobject
            GameObject prefab = null;

            //perform check if we already have a prefab in our project (null if none)
            if (AssetDatabase.LoadAssetAtPath(assetPath, typeof(GameObject)))
            {
                //display custom dialog and wait for user input to overwrite prefab
                if (EditorUtility.DisplayDialog("Are you sure?",
                                                "The prefab already exists. Do you want to overwrite it?",
                                                "Yes",
                                                "No"))
                {
                    //user clicked "Yes", create and overwrite existing prefab
                    prefab = PrefabUtility.CreatePrefab(assetPath, projectileModel.gameObject);
                }
            }
            else
            {
                //we haven't created a prefab before nor the project contains one,
                //create prefab next to the model at assetPath
                prefab = PrefabUtility.CreatePrefab(assetPath, projectileModel.gameObject);
            }

            //destroy temporary instantiated projectile model in the editor
            DestroyImmediate(projectileModel.gameObject);
            //if we created a prefab
            if (prefab)
            {
                //select it within the project panel
                Selection.activeGameObject = prefab;
                //close this editor window
                this.Close();
            }
        }
    }
コード例 #16
0
        protected override void RenderContent(UnityEngine.Object undoRecordObject)
        {
            bool          newBool; float newFloat; int newInt;
            TransformAxis newTransformAxis;

            EditorGUILayoutEx.SectionHeader("Alignment");
            var content = new GUIContent();

            content.text    = "Align axis";
            content.tooltip = "If this is checked, the grabbed objects will have their local axes aligned with the grab surface normal.";
            newBool         = EditorGUILayout.ToggleLeft(content, AlignAxis);
            if (newBool != AlignAxis)
            {
                EditorUndoEx.Record(undoRecordObject);
                AlignAxis = newBool;
            }

            content.text     = "Alignment axis";
            content.tooltip  = "When axis alignment is turned on, this is the axis that will be aligned to the surface normal.";
            newTransformAxis = (TransformAxis)EditorGUILayout.EnumPopup(content, AlignmentAxis);
            if (newTransformAxis != AlignmentAxis)
            {
                EditorUndoEx.Record(undoRecordObject);
                AlignmentAxis = newTransformAxis;
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Sensitivity");
            content.text    = "Rotation";
            content.tooltip = "Allows you to control how sensitive object rotation is to the input device.";
            newFloat        = EditorGUILayout.FloatField(content, RotationSensitivity);
            if (newFloat != RotationSensitivity)
            {
                EditorUndoEx.Record(undoRecordObject);
                RotationSensitivity = newFloat;
            }

            content.text    = "Scale";
            content.tooltip = "Allows you to control how sensitive object scaling is to the input device.";
            newFloat        = EditorGUILayout.FloatField(content, ScaleSensitivity);
            if (newFloat != ScaleSensitivity)
            {
                EditorUndoEx.Record(undoRecordObject);
                ScaleSensitivity = newFloat;
            }

            content.text    = "Offset from surface";
            content.tooltip = "Sensitivity value used when offseting objects from the surface on which they are sitting.";
            newFloat        = EditorGUILayout.FloatField(content, OffsetFromSurfaceSensitivity);
            if (newFloat != OffsetFromSurfaceSensitivity)
            {
                EditorUndoEx.Record(undoRecordObject);
                OffsetFromSurfaceSensitivity = newFloat;
            }

            content.text    = "Offset from anchor";
            content.tooltip = "Sensitivity value used when offseting objects from the anchor point.";
            newFloat        = EditorGUILayout.FloatField(content, OffsetFromAnchorSensitivity);
            if (newFloat != OffsetFromAnchorSensitivity)
            {
                EditorUndoEx.Record(undoRecordObject);
                OffsetFromAnchorSensitivity = newFloat;
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Surface");
            content.text    = "Default offset";
            content.tooltip = "A default offset value which controls the distance between the objects and the surface they are sitting on. Negative values can be used to embed objects in the surface.";
            newFloat        = EditorGUILayout.FloatField(content, DefaultOffsetFromSurface);
            if (newFloat != DefaultOffsetFromSurface)
            {
                EditorUndoEx.Record(undoRecordObject);
                DefaultOffsetFromSurface = newFloat;
            }

            content.text    = "Surface flags";
            content.tooltip = "Allows you to specify the types of surfaces that can be used during a grab session.";
            newInt          = (int)((ObjectGrabSurfaceFlags)EditorGUILayout.EnumMaskPopup(content, (ObjectGrabSurfaceFlags)SurfaceFlags));
            if (newInt != (int)SurfaceFlags)
            {
                EditorUndoEx.Record(undoRecordObject);
                SurfaceFlags = (ObjectGrabSurfaceFlags)newInt;
            }

            content.text    = "Surface layers";
            content.tooltip = "Allows you to specify which layers can be used as snap surface during a grab session.";
            newInt          = EditorGUILayoutEx.LayerMaskField(content, SurfaceLayers);
            if (newInt != SurfaceLayers)
            {
                EditorUndoEx.Record(undoRecordObject);
                SurfaceLayers = newInt;
            }

            content.text    = "Spherical mesh layers";
            content.tooltip = "Objects that belong to these layers will be treated as spherical meshes (spheres). This allows the system to make " +
                              "certain assumptions about the surface geometry in order to produce the correct results.";
            newInt = EditorGUILayoutEx.LayerMaskField(content, SphericalMeshLayers);
            if (newInt != SphericalMeshLayers)
            {
                EditorUndoEx.Record(undoRecordObject);
                SphericalMeshLayers = newInt;
            }

            content.text    = "Terrain mesh layers";
            content.tooltip = "Objects that belong to these layers will be treated as terrain meshes (meshes that resemble a terrain but are NOT Unity Terrains). This allows the system to make " +
                              "certain assumptions about the surface geometry in order to produce the correct results.";
            newInt = EditorGUILayoutEx.LayerMaskField(content, TerrainMeshLayers);
            if (newInt != TerrainMeshLayers)
            {
                EditorUndoEx.Record(undoRecordObject);
                TerrainMeshLayers = newInt;
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Per layer settings");
            EditorGUILayout.BeginHorizontal();
            content.text    = "Add";
            content.tooltip = "Adds grab settings which apply only to the chosen layer. Objects which belong to that layer will use these settings during a grab session.";
            if (GUILayout.Button(content, GUILayout.Width(70.0f)))
            {
                EditorUndoEx.Record(undoRecordObject);
                GetLayerGrabSettings(_newLayer).IsActive = true;
            }

            newInt = EditorGUILayout.LayerField(_newLayer);
            if (newInt != _newLayer)
            {
                EditorUndoEx.Record(undoRecordObject);
                _newLayer = newInt;
            }
            EditorGUILayout.EndHorizontal();

            foreach (var layerGrabSettings in _layerGrabSettings)
            {
                if (layerGrabSettings.IsActive)
                {
                    EditorGUILayout.BeginVertical("Box");
                    EditorGUILayout.HelpBox(LayerMask.LayerToName(layerGrabSettings.Layer), MessageType.None);

                    content.text    = "Align axis";
                    content.tooltip = "If this is checked, the grabbed objects that belong to this layer will have their local axes aligned with the grab surface normal.";
                    newBool         = EditorGUILayout.ToggleLeft(content, layerGrabSettings.AlignAxis);
                    if (newBool != layerGrabSettings.AlignAxis)
                    {
                        EditorUndoEx.Record(undoRecordObject);
                        layerGrabSettings.AlignAxis = newBool;
                    }

                    content.text     = "Alignment axis";
                    content.tooltip  = "When axis alignment is turned on, this is the axis that will be aligned to the surface normal.";
                    newTransformAxis = (TransformAxis)EditorGUILayout.EnumPopup(content, layerGrabSettings.AlignmentAxis);
                    if (newTransformAxis != layerGrabSettings.AlignmentAxis)
                    {
                        EditorUndoEx.Record(undoRecordObject);
                        layerGrabSettings.AlignmentAxis = newTransformAxis;
                    }

                    content.text    = "Default offset from surface";
                    content.tooltip = "A default offset value which controls the distance between the objects and the surface they are sitting on. Negative values can be used to embed objects in the surface.";
                    newFloat        = EditorGUILayout.FloatField(content, layerGrabSettings.DefaultOffsetFromSurface);
                    if (newFloat != layerGrabSettings.DefaultOffsetFromSurface)
                    {
                        EditorUndoEx.Record(undoRecordObject);
                        layerGrabSettings.DefaultOffsetFromSurface = newFloat;
                    }

                    content.text    = "Remove";
                    content.tooltip = "Removes the settings for this layer.";
                    if (GUILayout.Button(content, GUILayout.Width(70.0f)))
                    {
                        EditorUndoEx.Record(undoRecordObject);
                        layerGrabSettings.IsActive = false;
                    }
                    EditorGUILayout.EndVertical();
                }
            }
        }
コード例 #17
0
    // ReSharper disable once FunctionComplexityOverflow
    public override void OnInspectorGUI()
    {
        MasterAudio.Instance = null;

        var ma        = MasterAudio.Instance;
        var maInScene = ma != null;

        if (maInScene)
        {
            DTGUIHelper.ShowHeaderTexture(MasterAudioInspectorResources.LogoTexture);
            _groupNames = ma.GroupNames;
        }
        else
        {
            _groupNames = new List <string>();
        }
        PopulateGroupNames(_groupNames);

        DTGUIHelper.HelpHeader("http://www.dtdevtools.com/docs/masteraudio/FootstepSounds.htm");

        _isDirty = false;

        _sounds = (FootstepSounds)target;

        var newSpawnMode = (MasterAudio.SoundSpawnLocationMode)EditorGUILayout.EnumPopup("Sound Spawn Mode", _sounds.soundSpawnMode);

        if (newSpawnMode != _sounds.soundSpawnMode)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Sound Spawn Mode");
            _sounds.soundSpawnMode = newSpawnMode;
        }

        var newEvent = (FootstepSounds.FootstepTriggerMode)EditorGUILayout.EnumPopup("Event Used", _sounds.footstepEvent);

        if (newEvent != _sounds.footstepEvent)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Event Used");
            _sounds.footstepEvent = newEvent;
        }

        if (_sounds.footstepEvent == FootstepSounds.FootstepTriggerMode.None)
        {
            DTGUIHelper.ShowRedError("No sound will be made when Event Used is set to None.");
            return;
        }

        DTGUIHelper.VerticalSpace(3);

#if PHY3D_MISSING
        switch (_sounds.footstepEvent)
        {
        case FootstepSounds.FootstepTriggerMode.OnCollision:
        case FootstepSounds.FootstepTriggerMode.OnTriggerEnter:
            DTGUIHelper.ShowRedError("You cannot use Physics3D events because you do not have the Physics3D package installed. This script will not work.");
            return;
        }
#endif
#if PHY2D_MISSING
        switch (_sounds.footstepEvent)
        {
        case FootstepSounds.FootstepTriggerMode.OnCollision2D:
        case FootstepSounds.FootstepTriggerMode.OnTriggerEnter2D:
            DTGUIHelper.ShowRedError("You cannot use Physics2D events because you do not have the Physics2D package installed. This script will not work.");
            return;
        }
#endif

        EditorGUILayout.BeginHorizontal();
        GUI.contentColor = DTGUIHelper.BrightButtonColor;
        GUILayout.Space(10);
        if (GUILayout.Button("Add Footstep Sound", EditorStyles.toolbarButton, GUILayout.Width(125)))
        {
            AddFootstepSound();
        }

        if (_sounds.footstepGroups.Count > 0)
        {
            GUILayout.Space(10);
            if (GUILayout.Button(new GUIContent("Delete Footstep Sound", "Delete the bottom Footstep Sound"), EditorStyles.toolbarButton, GUILayout.Width(125)))
            {
                DeleteFootstepSound();
            }
            var buttonText   = "Collapse All";
            var allCollapsed = true;

            foreach (var t in _sounds.footstepGroups)
            {
                if (!t.isExpanded)
                {
                    continue;
                }

                allCollapsed = false;
                break;
            }

            if (allCollapsed)
            {
                buttonText = "Expand All";
            }

            GUILayout.Space(10);
            if (GUILayout.Button(new GUIContent(buttonText), EditorStyles.toolbarButton, GUILayout.Width(80)))
            {
                _isDirty = true;
                ExpandCollapseAll(allCollapsed);
            }
        }

        GUI.contentColor = Color.white;
        EditorGUILayout.EndHorizontal();
        DTGUIHelper.VerticalSpace(3);

        DTGUIHelper.StartGroupHeader();
        var newRetrigger = (EventSounds.RetriggerLimMode)EditorGUILayout.EnumPopup("Retrigger Limit Mode", _sounds.retriggerLimitMode);
        if (newRetrigger != _sounds.retriggerLimitMode)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Retrigger Limit Mode");
            _sounds.retriggerLimitMode = newRetrigger;
        }
        EditorGUILayout.EndVertical();

        EditorGUI.indentLevel = 0;
        switch (_sounds.retriggerLimitMode)
        {
        case EventSounds.RetriggerLimMode.FrameBased:
            var newFrm = EditorGUILayout.IntSlider("Min Frames Between", _sounds.limitPerXFrm, 0, 10000);
            if (newFrm != _sounds.limitPerXFrm)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Min Frames Between");
                _sounds.limitPerXFrm = newFrm;
            }
            break;

        case EventSounds.RetriggerLimMode.TimeBased:
            var newSec = EditorGUILayout.Slider("Min Seconds Between", _sounds.limitPerXSec, 0f, 10000f);
            if (newSec != _sounds.limitPerXSec)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Min Seconds Between");
                _sounds.limitPerXSec = newSec;
            }
            break;
        }
        EditorGUILayout.EndVertical();

        EditorGUI.indentLevel = 0;
        if (_sounds.footstepGroups.Count == 0)
        {
            DTGUIHelper.ShowRedError("You have no Footstep Sounds configured.");
        }
        for (var f = 0; f < _sounds.footstepGroups.Count; f++)
        {
            EditorGUI.indentLevel = 1;
            var step = _sounds.footstepGroups[f];


            var state = step.isExpanded;
            var text  = "Footstep Sound #" + (f + 1);

            DTGUIHelper.ShowCollapsibleSection(ref state, text);

            GUI.backgroundColor = Color.white;
            GUILayout.Space(3f);

            if (state != step.isExpanded)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "toggle Expand Variation");
                step.isExpanded = state;
            }

            DTGUIHelper.AddHelpIconNoStyle("http://www.dtdevtools.com/docs/masteraudio/FootstepSounds.htm#FootstepSound");

            EditorGUILayout.EndHorizontal();

            if (!step.isExpanded)
            {
                DTGUIHelper.VerticalSpace(3);
                continue;
            }

            EditorGUI.indentLevel = 0;
            DTGUIHelper.BeginGroupedControls();

            DTGUIHelper.StartGroupHeader();

            var newUseLayers = EditorGUILayout.BeginToggleGroup("Layer filters", step.useLayerFilter);
            if (newUseLayers != step.useLayerFilter)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "toggle Layer filters");
                step.useLayerFilter = newUseLayers;
            }
            DTGUIHelper.EndGroupHeader();

            if (step.useLayerFilter)
            {
                for (var i = 0; i < step.matchingLayers.Count; i++)
                {
                    var newLayer = EditorGUILayout.LayerField("Layer Match " + (i + 1), step.matchingLayers[i]);
                    if (newLayer == step.matchingLayers[i])
                    {
                        continue;
                    }

                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Layer filter");
                    step.matchingLayers[i] = newLayer;
                }
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(10);

                GUI.contentColor = DTGUIHelper.BrightButtonColor;
                if (GUILayout.Button(new GUIContent("Add", "Click to add a layer match at the end"), EditorStyles.toolbarButton, GUILayout.Width(60)))
                {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "add Layer filter");
                    step.matchingLayers.Add(0);
                }
                if (step.matchingLayers.Count > 1)
                {
                    GUILayout.Space(10);
                    if (GUILayout.Button(new GUIContent("Remove", "Click to remove the last layer match"), EditorStyles.toolbarButton, GUILayout.Width(60)))
                    {
                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "remove Layer filter");
                        step.matchingLayers.RemoveAt(step.matchingLayers.Count - 1);
                    }
                }
                GUI.contentColor = Color.white;
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndToggleGroup();

            DTGUIHelper.StartGroupHeader();
            var newTagFilter = EditorGUILayout.BeginToggleGroup("Tag filter", step.useTagFilter);
            if (newTagFilter != step.useTagFilter)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "toggle Tag filter");
                step.useTagFilter = newTagFilter;
            }
            DTGUIHelper.EndGroupHeader();

            if (step.useTagFilter)
            {
                for (var i = 0; i < step.matchingTags.Count; i++)
                {
                    var newTag = EditorGUILayout.TagField("Tag Match " + (i + 1), step.matchingTags[i]);
                    if (newTag == step.matchingTags[i])
                    {
                        continue;
                    }

                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Tag filter");
                    step.matchingTags[i] = newTag;
                }
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(10);
                GUI.contentColor = DTGUIHelper.BrightButtonColor;
                if (GUILayout.Button(new GUIContent("Add", "Click to add a tag match at the end"), EditorStyles.toolbarButton, GUILayout.Width(60)))
                {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "Add Tag filter");
                    step.matchingTags.Add("Untagged");
                }
                if (step.matchingTags.Count > 1)
                {
                    GUILayout.Space(10);
                    if (GUILayout.Button(new GUIContent("Remove", "Click to remove the last tag match"), EditorStyles.toolbarButton, GUILayout.Width(60)))
                    {
                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "remove Tag filter");
                        step.matchingTags.RemoveAt(step.matchingLayers.Count - 1);
                    }
                }
                GUI.contentColor = Color.white;
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndToggleGroup();

            EditorGUI.indentLevel = 0;

            if (maInScene)
            {
                var existingIndex = _groupNames.IndexOf(step.soundType);

                int?groupIndex = null;

                var noGroup = false;
                var noMatch = false;

                if (existingIndex >= 1)
                {
                    EditorGUILayout.BeginHorizontal();
                    groupIndex = EditorGUILayout.Popup("Sound Group", existingIndex, _groupNames.ToArray());
                    if (existingIndex == 1)
                    {
                        noGroup = true;
                    }

                    var button = DTGUIHelper.AddSettingsButton("Sound Group");
                    switch (button)
                    {
                    case DTGUIHelper.DTFunctionButtons.Go:
                        var grp = _groupNames[existingIndex];
                        var trs = MasterAudio.FindGroupTransform(grp);
                        if (trs != null)
                        {
                            Selection.activeObject = trs;
                        }
                        break;
                    }

                    EditorGUILayout.EndHorizontal();
                }
                else if (existingIndex == -1 && step.soundType == MasterAudio.NoGroupName)
                {
                    groupIndex = EditorGUILayout.Popup("Sound Group", existingIndex, _groupNames.ToArray());
                }
                else     // non-match
                {
                    noMatch = true;
                    var newSound = EditorGUILayout.TextField("Sound Group", step.soundType);
                    if (newSound != step.soundType)
                    {
                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Sound Group");
                        step.soundType = newSound;
                    }

                    var newIndex = EditorGUILayout.Popup("All Sound Groups", -1, _groupNames.ToArray());
                    if (newIndex >= 0)
                    {
                        groupIndex = newIndex;
                    }
                }

                if (noGroup)
                {
                    DTGUIHelper.ShowRedError("No Sound Group specified. Footstep will not sound.");
                }
                else if (noMatch)
                {
                    DTGUIHelper.ShowRedError("Sound Group found no match. Type in or choose one.");
                }

                if (groupIndex.HasValue)
                {
                    if (existingIndex != groupIndex.Value)
                    {
                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Sound Group");
                    }
                    // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
                    if (groupIndex.Value == -1)
                    {
                        step.soundType = MasterAudio.NoGroupName;
                    }
                    else
                    {
                        step.soundType = _groupNames[groupIndex.Value];
                    }
                }
            }
            else
            {
                var newSType = EditorGUILayout.TextField("Sound Group", step.soundType);
                if (newSType != step.soundType)
                {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Sound Group");
                    step.soundType = newSType;
                }
            }

            var newVarType = (EventSounds.VariationType)EditorGUILayout.EnumPopup("Variation Mode", step.variationType);
            if (newVarType != step.variationType)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Variation Mode");
                step.variationType = newVarType;
            }

            if (step.variationType == EventSounds.VariationType.PlaySpecific)
            {
                var newVarName = EditorGUILayout.TextField("Variation Name", step.variationName);
                if (newVarName != step.variationName)
                {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Variation Name");
                    step.variationName = newVarName;
                }

                if (string.IsNullOrEmpty(step.variationName))
                {
                    DTGUIHelper.ShowRedError("Variation Name is empty. No sound will play.");
                }
            }

            var newVol = DTGUIHelper.DisplayVolumeField(step.volume, DTGUIHelper.VolumeFieldType.None, MasterAudio.MixerWidthMode.Normal, 0f, true);
            // ReSharper disable once CompareOfFloatsByEqualityOperator
            if (newVol != step.volume)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Volume");
                step.volume = newVol;
            }

            var newFixedPitch = EditorGUILayout.Toggle("Override pitch?", step.useFixedPitch);
            if (newFixedPitch != step.useFixedPitch)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "toggle Override pitch");
                step.useFixedPitch = newFixedPitch;
            }
            if (step.useFixedPitch)
            {
                var newPitch = DTGUIHelper.DisplayPitchField(step.pitch);
                if (newPitch != step.pitch)
                {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Pitch");
                    step.pitch = newPitch;
                }
            }

            var newDelay = EditorGUILayout.Slider("Delay Sound (sec)", step.delaySound, 0f, 10f);
            if (newDelay == step.delaySound)
            {
                DTGUIHelper.EndGroupedControls();
                continue;
            }

            DTGUIHelper.EndGroupedControls();

            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Delay Sound");
            step.delaySound = newDelay;
        }

        if (GUI.changed || _isDirty)
        {
            EditorUtility.SetDirty(target);
        }

        //DrawDefaultInspector();
    }
コード例 #18
0
    public override void OnInspectorGUI()
    {
        this.serializedObject.Update();

        GUIContent content;

        EditorGUI.indentLevel       = 0;
        EditorGUIUtility.labelWidth = PGEditorUtils.CONTROLS_DEFAULT_LABEL_WIDTH;

        Object[] targetObjs = this.serializedObject.targetObjects;

        AreaTargetTracker curEditTarget;


        content = new GUIContent(
            "Targets (-1 for all)",
            "The number of targets to return. Set to -1 to return all targets"
            );
        EditorGUILayout.PropertyField(this.numberOfTargets, content);

        content = new GUIContent
                  (
            "Target Layers",
            "The layers in which the area is allowed to find targets."
                  );
        EditorGUILayout.PropertyField(this.targetLayers, content);

        EditorGUI.BeginChangeCheck();
        content = new GUIContent("Sorting Style", "The style of sorting to use");
        EditorGUILayout.PropertyField(this.sortingStyle, content);

        var sortingStyle = (TargetTracker.SORTING_STYLES) this.sortingStyle.enumValueIndex;

        // If changed, trigger the property setter for all objects being edited
        if (EditorGUI.EndChangeCheck())
        {
            for (int i = 0; i < targetObjs.Length; i++)
            {
                curEditTarget = (AreaTargetTracker)targetObjs[i];

                Undo.RecordObject(curEditTarget, targetObjs[0].GetType() + " sortingStyle");

                curEditTarget.sortingStyle = sortingStyle;
            }
        }

        if (sortingStyle != TargetTracker.SORTING_STYLES.None)
        {
            EditorGUI.indentLevel += 1;

            content = new GUIContent(
                "Minimum Interval",
                "How often the target list will be sorted. If set to 0, " +
                "sorting will only be triggered when Targets enter or exit range."
                );
            EditorGUILayout.PropertyField(this.updateInterval, content);

            EditorGUI.indentLevel -= 1;
        }

        this.showArea = EditorGUILayout.Foldout(this.showArea, "Area Settings");

        if (this.showArea)
        {
            EditorGUI.indentLevel += 1;

            EditorGUI.BeginChangeCheck();
            content = new GUIContent
                      (
                "Area Layer",
                "The layer to put the area in."
                      );
            content = EditorGUI.BeginProperty(new Rect(0, 0, 0, 0), content, this.areaLayer);

            int layer = EditorGUILayout.LayerField(content, this.areaLayer.intValue);

            // If changed, trigger the property setter for all objects being edited
            if (EditorGUI.EndChangeCheck())
            {
                for (int i = 0; i < targetObjs.Length; i++)
                {
                    curEditTarget = (AreaTargetTracker)targetObjs[i];

                    Undo.RecordObject(curEditTarget, targetObjs[0].GetType() + " areaLayer");

                    curEditTarget.areaLayer = layer;
                }
            }
            EditorGUI.EndProperty();


            EditorGUILayout.BeginHorizontal();

            EditorGUI.BeginChangeCheck();
            content = new GUIContent
                      (
                "Area Shape",
                "The shape of the area used to detect targets in range"
                      );
            EditorGUILayout.PropertyField(this.areaShape, content);

            // If changed, trigger the property setter for all objects being edited
            if (EditorGUI.EndChangeCheck())
            {
                var shape = (AreaTargetTracker.AREA_SHAPES) this.areaShape.enumValueIndex;

                string undo_message = targetObjs[0].GetType() + " areaShape";

                for (int i = 0; i < targetObjs.Length; i++)
                {
                    curEditTarget = (AreaTargetTracker)targetObjs[i];

                    if (curEditTarget.area != null)                      // Only works at runtime.
                    {
//						// This would have happened anyway, but this way is undoable
//						if (curEditTarget.area.coll != null)
//						{
//							Undo.DestroyObjectImmediate(curEditTarget.area.coll);
//						}
//						else if (curEditTarget.area.coll2D != null)
//						{
//							Undo.DestroyObjectImmediate(curEditTarget.area.coll2D);
//						}

                        Undo.RecordObject(curEditTarget.area.transform, undo_message);
                    }

                    Undo.RecordObject(curEditTarget, undo_message);


                    // Property. Handles collider changes at runtime.
                    curEditTarget.areaShape = shape;
                }
            }


            Area area;
            bool ok;
            for (int i = 0; i < targetObjs.Length; i++)
            {
                curEditTarget = (AreaTargetTracker)targetObjs[i];
                area          = curEditTarget.area;
                ok            = false;

                if (area == null)
                {
                    continue;
                }


                if (area.coll != null)
                {
                    switch (curEditTarget.areaShape)
                    {
                    case AreaTargetTracker.AREA_SHAPES.Sphere:
                        if (area.coll is SphereCollider)
                        {
                            ok = true;
                        }

                        break;

                    case AreaTargetTracker.AREA_SHAPES.Box:
                        if (area.coll is BoxCollider)
                        {
                            ok = true;
                        }

                        break;

                    case AreaTargetTracker.AREA_SHAPES.Capsule:
                        if (area.coll is CapsuleCollider)
                        {
                            ok = true;
                        }

                        break;
                    }
                }
                else if (area.coll2D != null)
                {
                    switch (curEditTarget.areaShape)
                    {
                    case AreaTargetTracker.AREA_SHAPES.Box2D:
                        if (area.coll2D is BoxCollider2D)
                        {
                            ok = true;
                        }

                        break;

                    case AreaTargetTracker.AREA_SHAPES.Circle2D:
                        if (area.coll2D is CircleCollider2D)
                        {
                            ok = true;
                        }

                        break;
                    }
                }

                if (!ok)
                {
                    var shape = (AreaTargetTracker.AREA_SHAPES) this.areaShape.enumValueIndex;
                    curEditTarget.areaShape = shape;
                }
            }

            content = new GUIContent
                      (
                "Gizmo ",
                "Visualize the area in the Editor by turning this on."
                      );
            PGEditorUtils.ToggleButton(this.drawGizmo, content, 50);

            //script.drawGizmo = EditorGUILayout.Toggle(script.drawGizmo, GUILayout.MaxWidth(47));
            EditorGUILayout.EndHorizontal();

            if (this.drawGizmo.boolValue)
            {
                EditorGUI.indentLevel += 1;
                EditorGUILayout.BeginHorizontal();

                content = new GUIContent
                          (
                    "Gizmo Color",
                    "The color of the gizmo when displayed"
                          );
                EditorGUILayout.PropertyField(this.gizmoColor, content);

                // If clicked, reset the color to the default
                GUIStyle style = EditorStyles.miniButton;
                style.alignment  = TextAnchor.MiddleCenter;
                style.fixedWidth = 52;
                if (GUILayout.Button("Reset", style))
                {
                    for (int i = 0; i < targetObjs.Length; i++)
                    {
                        curEditTarget            = (AreaTargetTracker)targetObjs[i];
                        curEditTarget.gizmoColor = curEditTarget.defaultGizmoColor;
                    }
                }

                EditorGUILayout.EndHorizontal();

                EditorGUI.indentLevel -= 1;

                GUILayout.Space(4);
            }


            this.displayRange <AreaTargetTracker>(targetObjs);


            EditorGUI.BeginChangeCheck();
            content = new GUIContent
                      (
                "Position Offset",
                "An optional position offset for the area. For example, if you have an" +
                "object resting on the ground which has a range of 4, a position offset of" +
                "Vector3(0, 4, 0) will place your area so it is also sitting on the ground."
                      );
            EditorGUILayout.PropertyField(this.areaPositionOffset, content);

            // If changed, trigger the property setter for all objects being edited
            if (EditorGUI.EndChangeCheck())
            {
                string undo_message = targetObjs[0].GetType() + " areaPositionOffset";
                for (int i = 0; i < targetObjs.Length; i++)
                {
                    curEditTarget = (AreaTargetTracker)targetObjs[i];

                    Undo.RecordObject(curEditTarget, undo_message);

                    if (curEditTarget.area != null)                      // Only works at runtime.
                    {
                        Undo.RecordObject(curEditTarget.area.transform, undo_message);
                    }

                    curEditTarget.areaPositionOffset = this.areaPositionOffset.vector3Value;
                }
            }


            EditorGUI.BeginChangeCheck();
            content = new GUIContent
                      (
                "Rotation Offset",
                "An optional rotational offset for the area."
                      );
            EditorGUILayout.PropertyField(this.areaRotationOffset, content);

            // If changed, trigger the property setter for all objects being edited
            if (EditorGUI.EndChangeCheck())
            {
                string undo_message = targetObjs[0].GetType() + " areaPositionOffset";
                for (int i = 0; i < targetObjs.Length; i++)
                {
                    curEditTarget = (AreaTargetTracker)targetObjs[i];

                    Undo.RecordObject(curEditTarget, undo_message);

                    if (curEditTarget.area != null)                      // Only works at runtime.
                    {
                        Undo.RecordObject(curEditTarget.area.transform, undo_message);
                    }

                    curEditTarget.areaRotationOffset = this.areaRotationOffset.vector3Value;
                }
            }
        }

        EditorGUI.indentLevel -= 1;

        GUILayout.Space(8);

        content = new GUIContent
                  (
            "Debug Level", "Set it higher to see more verbose information."
                  );
        EditorGUILayout.PropertyField(this.debugLevel, content);

        serializedObject.ApplyModifiedProperties();

        // Flag Unity to save the changes to to the prefab to disk
        //   This is needed to make the gizmos update immediatly.
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
コード例 #19
0
ファイル: MapNavEditor.cs プロジェクト: qq456cvb/2D-Cute-Game
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        // gizmo related and info fields
        TMNEditorUtil.DrawSpacer();
        folds[4] = EditorGUILayout.Foldout(folds[4], folds[4] ? "" : "Gizmos");
        if (folds[4])
        {
            GUILayout.Label("Gizmos", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(gizmoDrawNodes);
            EditorGUILayout.PropertyField(gizmoDrawLinks);
            EditorGUILayout.PropertyField(gizmoColorCoding);
        }

        // info
        TMNEditorUtil.DrawSpacer();
        folds[5] = EditorGUILayout.Foldout(folds[5], folds[5] ? "" : "Basic Settings & Info");
        if (folds[5])
        {
            GUILayout.Label("Info", EditorStyles.boldLabel);
            EditorGUILayout.LabelField("MapNav Size: ", nodesCache.arraySize.ToString() + " (" + ((MapNav)target).nodesXCount + "x" + ((MapNav)target).nodesYCount + ")");
            EditorGUILayout.LabelField("Tiles Layout: ", ((MapNav.TilesLayout)tilesLayout.enumValueIndex).ToString());
            EditorGUILayout.LabelField("Tile Spacing: ", tileSpacing.floatValue.ToString());
            EditorGUILayout.LabelField("Tile Size: ", tileSize.floatValue.ToString());

            // basic fields
            EditorGUILayout.Space();
            GUILayout.Label("Basic Settings", EditorStyles.boldLabel);
            tilesLayer.intValue = EditorGUILayout.LayerField("Tiles Layer", tilesLayer.intValue);
            EditorGUILayout.PropertyField(oneUnitPerTileOnly);
            oneUnitExceptionAllowMoveOver.boolValue = EditorGUILayout.Toggle("One Unit Exception", oneUnitExceptionAllowMoveOver.boolValue);
        }

        // ...
        serializedObject.ApplyModifiedProperties();

        TMNEditorUtil.DrawSpacer();

        // fields to create new tile grid
        folds[0] = TMNEditorUtil.BeginToggleGroup("TileNodes Create Tool", folds[0]);
        if (folds[0])
        {
            GUILayout.Label("Note that this will delete current nodes", EditorStyles.label);
            EditorGUILayout.Space();
            new_TileNodeFab     = (GameObject)EditorGUILayout.ObjectField("TileNode Prefab", new_TileNodeFab, typeof(GameObject), false);
            new_tilesLayout     = EditorGUILayout.Popup("Tiles Layout", new_tilesLayout, MapNavEditor.TilesLayoutStrings);
            new_tileSpacing     = EditorGUILayout.FloatField("Tile Spacing", new_tileSpacing);
            new_tileSize        = EditorGUILayout.FloatField("Tile Size", new_tileSize);
            initialTileTypeMask = (TileNode.TileType)EditorGUILayout.EnumMaskField("Initial Tile Mask", initialTileTypeMask);

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Width x Length: ", EditorStyles.label);
            edNewNodesXY[0] = EditorGUILayout.IntField(edNewNodesXY[0]);
            edNewNodesXY[1] = EditorGUILayout.IntField(edNewNodesXY[1]);
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Create"))
            {
                tilesLayout.intValue   = new_tilesLayout;
                tileSpacing.floatValue = new_tileSpacing;
                tileSize.floatValue    = new_tileSize;

                if (edNewNodesXY[0] <= 0)
                {
                    edNewNodesXY[0] = 1;
                }
                if (edNewNodesXY[1] <= 0)
                {
                    edNewNodesXY[1] = 1;
                }

                //GameObject nodeFab = (GameObject)AssetDatabase.LoadAssetAtPath(MapNavEditor.PREFABS_PATH + "tile_nodes/" + ((MapNav.TilesLayout)new_tilesLayout == MapNav.TilesLayout.Hex ? "TIleNode_Hex.prefab" : "TIleNode_Square.prefab"), typeof(GameObject));
                //MapNav.CreateTileNodes(nodeFab, ((MapNav)target), (MapNav.TilesLayout)new_tilesLayout, new_tileSpacing, new_tileSize, initialTileTypeMask, edNewNodesXY[0], edNewNodesXY[1]);
                if (new_TileNodeFab != null)
                {
                    MapNav.CreateTileNodes(new_TileNodeFab, ((MapNav)target), (MapNav.TilesLayout)new_tilesLayout, new_tileSpacing, new_tileSize, initialTileTypeMask, edNewNodesXY[0], edNewNodesXY[1]);
                    ((MapNav)target).LinkNodes();
                }
            }
        }
        EditorGUILayout.EndToggleGroup();

        // various tools
        if (((MapNav)target).nodesCache != null)
        {
            // hide show node markers
            folds[1] = TMNEditorUtil.BeginToggleGroup("TileNodes Marker Visibility", folds[1]);
            if (folds[1])
            {
                GUILayout.Space(10f);
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Show"))
                {
                    ((MapNav)target).ShowTileNodeMarkers(true);
                    EditorUtility.SetDirty(target);
                }
                if (GUILayout.Button("Hide"))
                {
                    ((MapNav)target).ShowTileNodeMarkers(false);
                    EditorUtility.SetDirty(target);
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndToggleGroup();

            // automated setup of nodes' masks
            folds[2] = TMNEditorUtil.BeginToggleGroup("TileNodes Auto Mask-Setup Tool", folds[2]);
            if (folds[2])
            {
                GUILayout.Space(10f);
                maskAutomation_ParentObject = (Transform)EditorGUILayout.ObjectField("Use Parent Object", maskAutomation_ParentObject, typeof(Transform), true);
                if (maskAutomation_ParentObject != null)
                {
                    maskAutomation_ColliderMask = 0;
                }
                maskAutomation_ColliderMask = EditorGUILayout.LayerField("or use Colliders Layer", maskAutomation_ColliderMask);
                if (maskAutomation_ColliderMask != 0)
                {
                    maskAutomation_ParentObject = null;
                }
                GUILayout.Space(10f);
                maskAutomation_AddMask = (TileNode.TileType)EditorGUILayout.EnumMaskField("New TileNode Mask", maskAutomation_AddMask);
                GUILayout.Space(10f);
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Set"))
                {
                    if (maskAutomation_ParentObject != null)
                    {
                        ((MapNav)target).SetTileNodeMasks(maskAutomation_AddMask, maskAutomation_ParentObject);
                    }
                    else
                    {
                        ((MapNav)target).SetTileNodeMasks(maskAutomation_AddMask, maskAutomation_ColliderMask);
                    }
                    EditorUtility.SetDirty(target);
                }
                if (GUILayout.Button("Add"))
                {
                    if (maskAutomation_ParentObject != null)
                    {
                        ((MapNav)target).AddToTileNodeMasks(maskAutomation_AddMask, maskAutomation_ParentObject);
                    }
                    else
                    {
                        ((MapNav)target).AddToTileNodeMasks(maskAutomation_AddMask, maskAutomation_ColliderMask);
                    }
                    EditorUtility.SetDirty(target);
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.HelpBox("This tool helps automate the TileNode Mask setup process.\n\nExample, if you wanted to set nodes under tree meshes to be of Wall type, then you would set 'Parent Object' to the container of the trees and select from 'TileNode Mask' the Wall type (if you defined such in TileNode.TileType) and hit Add/Set.\n\nThe tool will go through all child transforms of the Parent Object and check which nodes are under them and update their tile-type masks.\n\nNote that 'Add' will add the mask to a node's current mask while 'Set' will reset the node mask to the given mask.\n\nYou also have the option to rather check against colliders of objects in your scene. This is useful where an object like a wall might span more than one tile and you want those tiles all to be set to tile type, wall. In this case you want to set 'Colliders Layer' to the layer of the objects to test against and make sure they have colliders since this will use ray casting. Make sure 'Parent Object' is not set in this case else this option will be ignored and Parent Object will be used.", MessageType.None);
            }
            EditorGUILayout.EndToggleGroup();

            // reseting nodes' masks
            folds[3] = TMNEditorUtil.BeginToggleGroup("TileNodes Mask Reset Tool", folds[3]);
            if (folds[3])
            {
                GUILayout.Space(10f);
                maskAutomation_ResetMask = (TileNode.TileType)EditorGUILayout.EnumMaskField("Set all to", maskAutomation_ResetMask);
                if (GUILayout.Button("Reset"))
                {
                    ((MapNav)target).SetAllNodeMasksTo(maskAutomation_ResetMask);
                    EditorUtility.SetDirty(target);
                }
            }
            EditorGUILayout.EndToggleGroup();

            // calc node heights
            folds[6] = TMNEditorUtil.BeginToggleGroup("TileNodes Auto Height-Setup Tool ", folds[6]);
            if (folds[6])
            {
                GUILayout.Space(10f);
                heightAutomation_Mask     = EditorGUILayout.LayerField("Colliders Layer", heightAutomation_Mask);
                heightAutomation_DelNodes = EditorGUILayout.Toggle("Node Deletion Active", heightAutomation_DelNodes);
                if (GUILayout.Button("Run Setup"))
                {
                    ((MapNav)target).SetupNodeHeights(heightAutomation_Mask, heightAutomation_DelNodes);
                    EditorUtility.SetDirty(target);
                }
                EditorGUILayout.HelpBox("This tool helps automate the TileNodes height setup. Set the 'Layer' field to the layer used by objects that will determine what height the nodes must be placed at. It is important that the object (for example a variable height terrain) use the same layer and has a collider since this tool will use raycasts the determine at what height to place nodes.\n\nIf Node Deletion is Active, then nodes that did not find anything to adjust their heights against will be unlinked and deleted. This is usefull if you have a non-square terrain area with some overlapping nodes that won't be used and must be deleted.", MessageType.None);
            }
            EditorGUILayout.EndToggleGroup();

            // auto link setup
            folds[7] = TMNEditorUtil.BeginToggleGroup("TileNodes Auto Link-Setup Tool ", folds[7]);
            if (folds[7])
            {
                GUILayout.Space(10f);
                maxHeightBeforeLinkBreak = EditorGUILayout.FloatField("Max Height", maxHeightBeforeLinkBreak);
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Run Setup"))
                {
                    ((MapNav)target).SetupNodeLinkSwitches(maxHeightBeforeLinkBreak);
                    EditorUtility.SetDirty(target);
                }
                if (GUILayout.Button("Reset ALL"))
                {
                    ((MapNav)target).RemoveNodeLinkSwitches();
                    EditorUtility.SetDirty(target);
                }
                if (GUILayout.Button("Delete Unlinked"))
                {
                    ((MapNav)target).DeleteAllUnlinkedNodes();
                    EditorUtility.SetDirty(target);
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.HelpBox("This tool helps automate setting up the links betwene nodes, depending on the height difference betwene the nodes. Enter a max height and links between nodes will be turned off if the height difference between them are higher.\n\nThe 'Delete' button allows for the auto-deletion of all nodes that have no active links.", MessageType.None);
            }
            EditorGUILayout.EndToggleGroup();
        }
    }
コード例 #20
0
    //7
    //GUISkin myGUISkin;


    void OnGUI()
    {
        //SECTION5---------------
        // 直接サイズを指定する場合は、
        // GUILayout.Width/Heightを使う。
        buttonSize = EditorGUILayout.Vector2Field("ButtonSize", buttonSize);
        if (GUILayout.Button("サイズ指定ボタン", GUILayout.Width(buttonSize.x), GUILayout.Height(buttonSize.y)))
        {
            Debug.Log("サイズ指定ボタン");
        }

        // 自動的にサイズ変更される範囲を指定する場合は
        // GUILayout.MinWidth/MaxWidth/MinHeight/MaxHeightを使う。
        buttonMinSize = EditorGUILayout.Vector2Field("ButtonMinSize", buttonMinSize);
        buttonMaxSize = EditorGUILayout.Vector2Field("ButtonMaxSize", buttonMaxSize);
        if (GUILayout.Button("最小最大指定ボタン",
                             GUILayout.MinWidth(buttonMinSize.x), GUILayout.MinHeight(buttonMinSize.y),
                             GUILayout.MaxWidth(buttonMaxSize.x), GUILayout.MaxHeight(buttonMaxSize.y)))
        {
            Debug.Log("最小最大指定ボタン");
        }

        // 有効範囲内全体に広げるかどうかは
        // GUILayout.ExpandWidth/ExpandHeightで指定する。
        expandWidth  = EditorGUILayout.Toggle("ExpandWidth", expandWidth);
        expandHeight = EditorGUILayout.Toggle("ExpandHeight", expandHeight);
        if (GUILayout.Button("Expandボタン", GUILayout.ExpandWidth(expandWidth), GUILayout.ExpandHeight(expandHeight)))
        {
            Debug.Log("Expandボタン");
        }

        //end-SECTION5-----------------------

        //section6
        //動的できんかな
        rightSize = EditorGUILayout.IntSlider("Size", rightSize, 1, 20, GUILayout.ExpandWidth(false));

        GUI.skin       = Resources.Load <GUISkin>("Assets/Editor/MyGUISkin");
        rightScrollPos = EditorGUILayout.BeginScrollView(rightScrollPos, GUI.skin.box);
        {
            // スクロール範囲
            for (int y = 0; y < rightSize; y++)
            {
                EditorGUILayout.BeginHorizontal(GUI.skin.box);
                {
                    /*
                     * // ここの範囲は横並び
                     * EditorGUILayout.PrefixLabel("Index " + y);
                     *
                     * // 下に行くほどボタン数増やす
                     * for (int i = 0; i < y + 1; i++)
                     * {
                     *      // ボタン(横幅100px)
                     *      if (GUILayout.Button("Button" + i, GUILayout.Width(100)))
                     *      {
                     *              Debug.Log("Button" + i + "押したよ");
                     *      }
                     * }
                     */
                    objectFieldArray[y] = EditorGUILayout.ObjectField("LAYER " + y, objectFieldArray[y], typeof(Object), true);

                    if (objectFieldArray[y] != null)
                    {
                        inspectorTitlebar = EditorGUILayout.InspectorTitlebar(inspectorTitlebar, objectFieldArray[y]);
                        if (inspectorTitlebar)
                        {
                            EditorGUILayout.LabelField("チラッチラッ");
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            // こんな感じで横幅固定しなくても、範囲からはみ出すときにスクロールバー出してくれる。
        }
        EditorGUILayout.EndScrollView();

        //



        EditorGUILayout.LabelField("ようこそ! Unityエディタ拡張の沼へ!");         // やっぱり残しておこう。

        EditorGUILayout.LabelField("LabelField", "EditorGUILayoutはEditor拡張用に調整されてる系");

        EditorGUILayout.SelectableLabel("SelectableLabel : 選択してコピペできる。変更はできない");

        EditorGUILayout.BeginHorizontal(GUI.skin.box);
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            {
                toggle = EditorGUILayout.Toggle("Toggle", toggle);

                toggleLeft = EditorGUILayout.ToggleLeft("ToggleLeft", toggleLeft);

                foldout = EditorGUILayout.Foldout(foldout, "Foldout");
                if (foldout)
                {
                    EditorGUILayout.LabelField("チラッ");
                }
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical(GUI.skin.box);
            {
                textField = EditorGUILayout.TextField("TextField", textField);

                textArea = EditorGUILayout.TextArea(textArea);
            }
            EditorGUILayout.EndVertical();
        }
        EditorGUILayout.EndHorizontal();

        intField = EditorGUILayout.IntField("IntField", intField);

        intSlider = EditorGUILayout.IntSlider("IntSlider", intSlider, 0, 100);

        floatField = EditorGUILayout.FloatField("FloatField", floatField);

        slider = EditorGUILayout.Slider("Slider", slider, 0.0f, 100.0f);

        EditorGUILayout.MinMaxSlider(new GUIContent("MinMaxSlider"), ref minMaxSliderMinValue, ref minMaxSliderMaxValue, 0.0f, 100.0f);
        EditorGUILayout.LabelField("MinValue = ", minMaxSliderMinValue.ToString());
        EditorGUILayout.LabelField("MaxValue = ", minMaxSliderMaxValue.ToString());

        layer = EditorGUILayout.LayerField("LayerField", layer);

        tag = EditorGUILayout.TagField("TagField", tag);

        vector3Field = EditorGUILayout.Vector3Field("Vector3Field", vector3Field);

        rectField = EditorGUILayout.RectField("RectField", rectField);

        colorField = EditorGUILayout.ColorField("ColorField", colorField);

        boundsField = EditorGUILayout.BoundsField("BoundsField", boundsField);        //center,extends,3D範囲、Boundsは構造体らしい。

        curveField = EditorGUILayout.CurveField("CurveField", curveField);

        /*
         * objectField = EditorGUILayout.ObjectField("ObjectField", objectField, typeof(Object), true);
         *
         * if (objectField != null)
         * {
         *      inspectorTitlebar = EditorGUILayout.InspectorTitlebar(inspectorTitlebar, objectField);
         *      if (inspectorTitlebar)
         *      {
         *              EditorGUILayout.LabelField("チラッチラッ");
         *      }
         * }
         */

        EditorGUILayout.LabelField("ここからSpace");
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("ここまでSpace");

        EditorGUILayout.HelpBox("Heeeeeelllllp!!!!!", MessageType.Warning);
    }
コード例 #21
0
    public override void OnInspectorGUI()
    {
        if (uiManager != null && serializedObj != null)
        {
            // Update the serializedProperty - always do this in the beginning of OnInspectorGUI.
            serializedObj.Update();
            GUI.enabled = false;
            script      = EditorGUILayout.ObjectField("Script:", script, typeof(MonoScript), false) as MonoScript;
            GUI.enabled = true;

            if (!Application.isPlaying)
            {
                if (GUILayout.Button("Despawn Not Starting"))
                {
                    Debug.Log("Despawn not starting");
                    Undo.RegisterCreatedObjectUndo(uiManager, uiManager.name);
                    uiManager.DespawnAllScreensOnSceneThatAreNotInitial();
                }
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Spawn All"))
                {
                    SpawnAll();
                }
                if (GUILayout.Button("Despawn All"))
                {
                    DespawnAll();
                }
                GUILayout.EndHorizontal();
                if (GUILayout.Button("Create new Screen"))
                {
                    CreateNewScreen();
                }
                if (GUILayout.Button("Create Controller from Selected(Lock!)"))
                {
                    CreateFromSelected();
                }
                if (GUILayout.Button("Update Screen Ids"))
                {
                    UpdateIds();
                }
                if (GUILayout.Button("Update Prefab References"))
                {
                    UpdatePrefabs();
                }
            }
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Enable All"))
            {
                uiManager.SwitchAllScreens(true);
            }
            if (GUILayout.Button("Disable All"))
            {
                uiManager.SwitchAllScreens(false);
            }
            GUILayout.EndHorizontal();
            if (GUILayout.Button("Recalculate Screen Positions"))
            {
                uiManager.ResetAllPositions();
            }
            bool eliminated = false;
            if (!Application.isPlaying)
            {
                if (GUILayout.Button("Reset"))
                {
                    ResetManager();
                    eliminated = true;
                }
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(serializedObj.FindProperty("autoInitialize"));
            EditorGUILayout.PropertyField(serializedObj.FindProperty("dontDestroyOnLoad"));
            EditorGUILayout.PropertyField(serializedObj.FindProperty("justDisableOnScreenDeactivation"));
            EditorGUILayout.PropertyField(serializedObj.FindProperty("canvasScalerReferenceResolution"));
            EditorGUILayout.PropertyField(serializedObj.FindProperty("canvasScalerMode"));
            EditorGUILayout.PropertyField(serializedObj.FindProperty("canvasScalerScreenMatchMode"));
            EditorGUILayout.PropertyField(serializedObj.FindProperty("canvasMatchModeRange"));
            EditorGUILayout.PropertyField(serializedObj.FindProperty("canvasScalerPixelsPerUnit"));
            EditorGUILayout.PropertyField(serializedObj.FindProperty("screenPositionNumberOfColumns"));
            EditorGUILayout.PropertyField(serializedObj.FindProperty("addHelpFrameToCreatedScreens"));
            EditorGUILayout.PropertyField(serializedObj.FindProperty("helpFramePrefab"));
            EditorGUILayout.PropertyField(serializedObj.FindProperty("screenSeparation"));
            SerializedProperty mask = serializedObj.FindProperty("systemLayer");
            mask.intValue = EditorGUILayout.LayerField("System Layer", mask.intValue);

            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
            SerializedProperty list = serializedObj.FindProperty("allScreenControllers");


            int startSize = (uiManager.allScreenControllers != null ? uiManager.allScreenControllers.Count : 0);
            EditorGUILayout.PropertyField(list, new GUIContent("All Screen Controllers[" + startSize + "]"));

            if (list.isExpanded)
            {
                bool added = GUILayout.Button("+", EditorStyles.miniButton);
                if (added)
                {
                    //list.InsertArrayElementAtIndex(list.arraySize);
                    uiManager.CreateNewEmptyControllerAlone();
                }
                else
                {
                    //EditorGUILayout.SelectableLabel("Size   "+uiManager.allScreenControllers.Count);
                    if (!eliminated)
                    {
                        for (int i = 0; i < list.arraySize; i++)
                        {
                            SerializedProperty element   = list.GetArrayElementAtIndex(i);
                            string             elementId = element.FindPropertyRelative("uiUniqueId").stringValue;
                            EditorGUILayout.BeginHorizontal();
                            element.isExpanded = EditorGUILayout.Foldout(element.isExpanded, elementId);
                            if (GUILayout.Button("-", EditorStyles.miniButton, GUILayout.MaxWidth(30)))
                            {
                                uiManager.RemoveUIScreenManagerController(elementId, false);
                                break;
                            }
                            EditorGUILayout.EndHorizontal();

                            if (element.isExpanded)
                            {
                                EditorGUILayout.PropertyField(element);
                                EditorGUIHelper.LineSeparator();
                            }
                            EditorGUIHelper.LineSeparator();
                        }
                    }
                }
            }

            if (serializedObject != null)
            {
                // Apply changes to the serializedProperty - always do this in the end of OnInspectorGUI.
                serializedObject.ApplyModifiedProperties();
            }
        }
    }
コード例 #22
0
 public override int Layer(GUIContent label, int layer, GUIStyle style, Layout layout)
 {
     return(EditorGUILayout.LayerField(label, layer, style, layout));
 }
コード例 #23
0
    private void OnGUI()
    {
        this.Repaint();     // 强制重绘
        if (secondWindow || secondWindow2)
        {
            GUI.enabled = false;
        }
        GUILayout.Label(testStr);        // 文本格式:网虫虫      不可输入、不可选
        GUIStyle fontStyle = new GUIStyle();

        fontStyle.normal.background = null;                    //设置背景填充
        fontStyle.normal.textColor  = new Color(1, 0, 0);      //设置字体颜色
        fontStyle.fontStyle         = FontStyle.BoldAndItalic; // 字体加粗倾斜
        fontStyle.fontSize          = 18;                      //字体大小
        GUILayout.Label(testStr, fontStyle);                   // 文本格式:网虫虫      不可输入、不可选  添加字体样式
        GUILayout.TextField(testStr);                          // 文本格式:网虫虫      可输入、不可选
        EditorGUILayout.LabelField("姓名:", testStr);            // 文本格式: 姓名:网虫虫      不可输入、不可选
        testStr   = EditorGUILayout.TextField("姓名:", testStr); // 文本格式:姓名:网虫虫      可输入、不可选
        testInt   = EditorGUILayout.IntField("IntField:", testInt);
        testFloat = EditorGUILayout.FloatField("FloatField:", testFloat);
        testStr   = GUILayout.TextArea(testStr, GUILayout.Height(40)); // 区域输入文本
        EditorGUILayout.SelectableLabel(testStr);                      // 可选择文本
        testStr     = GUILayout.PasswordField(testStr, "*"[0]);
        testStr     = EditorGUILayout.PasswordField("密码:", testStr);
        floatSlider = EditorGUILayout.Slider(floatSlider, 1, 100);
        EditorGUILayout.MinMaxSlider(ref minValue, ref maxValue, -100, 100);
        testBool      = GUILayout.Toggle(testBool, "开关");
        testBool      = EditorGUILayout.Toggle("开关:", testBool);
        toolbarOption = GUILayout.Toolbar(toolbarOption, toolbarStr);
        switch (toolbarOption)
        {
        case 0:
            GUILayout.Label("1111111111111111111");
            break;

        case 1:
            GUILayout.Label("2222222222222222222");
            break;

        case 2:
            GUILayout.Label("3333333333333333333");
            break;
        }
        EditorGUILayout.Space();        // 空一行
        enumTest            = (EnumTest)EditorGUILayout.EnumPopup("Enum类型Popup:", enumTest);
        enumTest2           = (EnumTest)EditorGUILayout.EnumMaskField("Enum枚举多选:", enumTest2);
        enumInt             = EditorGUILayout.Popup("String类型Popup:", enumInt, names);
        selectedSize        = EditorGUILayout.IntPopup("Int类型Popup: ", selectedSize, names, sizes);
        tagStr              = EditorGUILayout.TagField("选择Tag:", tagStr);
        layerInt            = EditorGUILayout.LayerField("选择Layer:", layerInt);
        maskInt             = EditorGUILayout.MaskField("数组多选:", maskInt, names);
        testColor           = EditorGUILayout.ColorField("颜色:", testColor);
        GUI.backgroundColor = Color.magenta;     // 修改背景颜色
        testVector3         = EditorGUILayout.Vector3Field("Vector3坐标:", testVector3);
        GUI.backgroundColor = Color.green;
        testRect            = EditorGUILayout.RectField("Rect尺寸:", testRect);
        GUI.backgroundColor = Color.gray * 1.8f;        // 恢复背景默认颜色
        gameObject          = (GameObject)EditorGUILayout.ObjectField("任意类型 举例GameObject:", gameObject, typeof(GameObject));
        texture             = EditorGUILayout.ObjectField("任意类型 举例贴图", texture, typeof(Texture), true) as Texture;
        GUILayout.BeginHorizontal();
        GUILayout.Label("横向自动排列演示:");
        testStr  = GUILayout.PasswordField(testStr, "*"[0]);
        testBool = GUILayout.Toggle(testBool, "开关");
        GUILayout.Button("按钮");
        GUILayout.EndHorizontal();
        if (GUILayout.Button("点击按钮 弹出系统提示消息"))
        {
            ShowNotification(new GUIContent("这是网虫虫提示消息~~"));
        }
        if (GUILayout.Button("点击按钮 显示滚动视图"))
        {
            isShowScrollView = !isShowScrollView;
        }
        if (isShowScrollView)
        {
            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            for (int i = 0; i >= 0 & i < 100; i++)
            {
                GUILayout.Label(i.ToString());
            }
            GUILayout.EndScrollView();
        }
        if (GUILayout.Button("点击按钮 显示二级窗口"))
        {
            secondWindow = !secondWindow;
        }
        if (secondWindow)
        {
            GUI.enabled = true;
            BeginWindows();
            secondWindowRect = GUILayout.Window(1, secondWindowRect, SecondWindow, "二级窗口");
            EndWindows();
        }
        if (GUILayout.Button("点击按钮 绘制图形"))
        {
            secondWindow2 = !secondWindow2;
        }
        if (secondWindow2)
        {
            GUI.backgroundColor = Color.red / 2;     // 修改背景颜色
            GUI.enabled         = true;
            BeginWindows();
            secondWindowRect2 = GUILayout.Window(2, secondWindowRect2, SecondWindow2, "绘制图形");
            EndWindows();
        }
        GUI.backgroundColor = Color.gray * 1.8f;        // 恢复背景默认颜色
        GUI.enabled         = false;
        GUILayout.Button("置灰按钮");
        GUI.enabled = true;
    }
コード例 #24
0
    // The actual window code goes here
    void OnGUI()
    {
        int width  = (int)position.width;
        int width1 = width - 165;

        _scroll = EditorGUILayout.BeginScrollView(_scroll);
        {
            EditorGUILayout.BeginVertical("Box");
            _foldout_bspfile = EditorGUILayout.Foldout(_foldout_bspfile, "BSP File");
            if (_foldout_bspfile)
            {
                EditorGUILayout.BeginHorizontal();
                {
                    GUILayout.Label("Scene name");
                    ImportSettings.SceneName = GUILayout.TextField(ImportSettings.SceneName, 16, GUILayout.Width(width1));
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                {
                    GUILayout.Label("Bsp file path");
                    ImportSettings.BspPath = GUILayout.TextField(ImportSettings.BspPath, GUILayout.Width(width1 - 20 - 4));
                    if (GUILayout.Button("...", GUILayout.Width(20)))
                    {
                        var path = EditorUtility.OpenFilePanel("Select BSP file", "", "bsp");
                        if (!string.IsNullOrEmpty(path))
                        {
                            ImportSettings.BspPath = path;
                            if (string.IsNullOrEmpty(ImportSettings.SceneName))
                            {
                                ImportSettings.SceneName = System.IO.Path.GetFileNameWithoutExtension(path);
                            }
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();

                {
                    // Refresh loaded info
                    if (_last_bspPath != ImportSettings.BspPath)
                    {
                        _last_bspPath = ImportSettings.BspPath;

                        bool exists = File.Exists(_last_bspPath);

                        _bspVersion_name = exists ? BspLib.Bsp.BspFile.GetVersionName(_last_bspPath) : "File Not Found";

                        if (exists)
                        {
                            try
                            {
                                var bsp = new BspFile();
                                BspFile.LoadPackedTexturesFromFile(bsp, _last_bspPath);

                                {
                                    var packed = bsp.PackedGoldSourceTextures.ToArray();
                                    PackedTextures = new string[packed.Length];

                                    for (int i = 0; i < packed.Length; i++)
                                    {
                                        BspLib.Wad.Texture wt = packed[i];
                                        PackedTextures[i] = wt.Name;
                                    }
                                }

                                RequiredTextures = BspFile.GetUsedTextures(_last_bspPath);
                            }
                            catch
                            {
                                PackedTextures   = new string[0];
                                RequiredTextures = new string[0];
                            }
                        }
                        else
                        {
                            PackedTextures   = new string[0];
                            RequiredTextures = new string[0];
                        }
                    }

                    EditorGUILayout.LabelField("Version", _bspVersion_name);
                }
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical("Box");
            {
                _foldout_textures = EditorGUILayout.Foldout(_foldout_textures, "Textures");
                if (_foldout_textures)
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Texture lookup directory");
                        ImportSettings.TextureLookupDirectory = GUILayout.TextField(ImportSettings.TextureLookupDirectory, GUILayout.Width(width1 - 20 - 4));
                        if (GUILayout.Button("...", GUILayout.Width(20)))
                        {
                            var path = EditorUtility.OpenFolderPanel("Select Texture lookup directory", "", ImportSettings.TextureLookupDirectory);
                            if (!string.IsNullOrEmpty(path))
                            {
                                ImportSettings.TextureLookupDirectory = path;
                            }
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Missing Texture Color");

                        ImportSettings.MissingTextureColor = EditorGUILayout.ColorField(ImportSettings.MissingTextureColor);
                    }
                    EditorGUILayout.EndHorizontal();

                    var missing = RequiredTextures.Where((t) => t != null && (PackedTextures == null || !PackedTextures.Any((texture) => texture != t)) && !File.Exists(Path.Combine(ImportSettings.TextureLookupDirectory, t + ".png"))).ToArray();
                    if (missing.Any())
                    {
                        EditorGUILayout.BeginVertical("Box");
                        {
                            _foldout_textures_missing = EditorGUILayout.Foldout(_foldout_textures_missing, "Missing");
                            if (_foldout_textures_missing)
                            {
                                foreach (var m in missing)
                                {
                                    GUILayout.Label(m);
                                }
                            }
                        }
                        EditorGUILayout.EndVertical();
                    }

                    if (PackedTextures.Length > 0)
                    {
                        EditorGUILayout.BeginVertical("Box");
                        {
                            _foldout_textures_packed = EditorGUILayout.Foldout(_foldout_textures_packed, "Packed Textures");
                            if (_foldout_textures_packed)
                            {
                                foreach (string pt in PackedTextures)
                                {
                                    GUILayout.Label(pt);
                                }
                            }
                        }
                        EditorGUILayout.EndVertical();
                    }
                }
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical("Box");
            {
                _foldout_scale = EditorGUILayout.Foldout(_foldout_scale, "Scale");
                if (_foldout_scale)
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        float scale = EditorGUILayout.FloatField("Value", ImportSettings.Scale);
                        if (scale != ImportSettings.Scale)
                        {
                            ImportSettings.Scale = scale;

                            if (scale == Scale1hu)
                            {
                                _popup_scale_id = 1;
                            }
                            else if (scale == Scale16hu)
                            {
                                _popup_scale_id = 2;
                            }
                            else if (scale == Scale1ft)
                            {
                                _popup_scale_id = 3;
                            }
                            else if (scale == Scale1m)
                            {
                                _popup_scale_id = 4;
                            }
                            else
                            {
                                _popup_scale_id = 0;
                            }
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.PrefixLabel("Preset");
                        _popup_scale_id = EditorGUILayout.Popup(_popup_scale_id, new string[] { "<custom>", "1 hammer", "16 hammer", "1 feet", "1 meter" });
                        switch (_popup_scale_id)
                        {
                        default:
                            break;

                        case 1:
                            ImportSettings.Scale = Scale1hu;
                            break;

                        case 2:
                            ImportSettings.Scale = Scale16hu;
                            break;

                        case 3:
                            ImportSettings.Scale = Scale1ft;
                            break;

                        case 4:
                            ImportSettings.Scale = Scale1m;
                            break;
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.BeginVertical("Box");
                        {
                            GUILayout.Label("1 in Hammer", EditorStyles.boldLabel);
                            GUILayout.Label(string.Format("{0} in Unity3D", ImportSettings.Scale * 16));
                            GUILayout.Label(string.Format("{0} feet", 1 / 16f));
                            GUILayout.Label(string.Format("{0} meter", 1 / 16f * 0.3048f));
                        }
                        EditorGUILayout.EndVertical();

                        EditorGUILayout.BeginVertical("Box");
                        {
                            GUILayout.Label("1 in Unity3D", EditorStyles.boldLabel);
                            float hu = 16f * ImportSettings.Scale;
                            GUILayout.Label(string.Format("{0} in Hammer", hu));
                            GUILayout.Label(string.Format("{0} feet", hu / 16f));
                            GUILayout.Label(string.Format("{0} meter", (hu / 16f) * 0.3048f));
                        }
                        EditorGUILayout.EndVertical();
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical("Box");
            {
                _foldout_settings = EditorGUILayout.Foldout(_foldout_settings, "Settings");
                if (_foldout_settings)
                {
                    ImportSettings.Colliders = (BspImportSettings.CollidersEnum)EditorGUILayout.EnumPopup("Generate colliders", ImportSettings.Colliders);


                    ImportSettings.LightMap = EditorGUILayout.Toggle("Import light map", ImportSettings.LightMap);
                    ImportSettings.Sky      = EditorGUILayout.Toggle("Import sky mesh", ImportSettings.Sky);

                    ImportSettings.Model0Layer     = EditorGUILayout.LayerField("Model 0 (solid) mask", ImportSettings.Model0Layer);
                    ImportSettings.OtherModelLayer = EditorGUILayout.LayerField("Other models (entities) mask", ImportSettings.OtherModelLayer);

                    EditorGUILayout.BeginVertical("Box");
                    {
                        ImportSettings.Entities = EditorGUILayout.ToggleLeft("Import Entities", ImportSettings.Entities);

                        if (ImportSettings.Entities)
                        {
                            EditorGUILayout.BeginHorizontal();
                            {
                                if (GUILayout.Button("None", GUILayout.Width(50)))
                                {
                                    ImportSettings.SetAllEntities(false);
                                }
                                if (GUILayout.Button("All", GUILayout.Width(50)))
                                {
                                    ImportSettings.SetAllEntities(true);
                                }
                            }
                            EditorGUILayout.EndHorizontal();

                            EditorGUILayout.Space();

                            ImportSettings.LightEntities = EditorGUILayout.ToggleLeft("Light entities (light, light_environment, light_spot)", ImportSettings.LightEntities);
                            if (ImportSettings.LightEntities)
                            {
                                ImportSettings.LightMask            = EditorGUILayout.LayerField("Light mask", ImportSettings.LightMask);
                                ImportSettings.LightEntitiesEnabled = EditorGUILayout.ToggleLeft("Enable light component", ImportSettings.LightEntitiesEnabled);
                            }

                            ImportSettings.BuyzoneEntity   = EditorGUILayout.ToggleLeft("Buy zone (func_buyzone)", ImportSettings.BuyzoneEntity);
                            ImportSettings.BombPlantEntity = EditorGUILayout.ToggleLeft("Bomb plant (func_bomb_target)", ImportSettings.BombPlantEntity);
                            GUI.enabled = false;
                            ImportSettings.WallEntity        = EditorGUILayout.ToggleLeft("Wall (func_wall)", ImportSettings.WallEntity);
                            ImportSettings.IllusionaryEntity = EditorGUILayout.ToggleLeft("Illusionary wall (func_illusionary)", ImportSettings.IllusionaryEntity);
                            ImportSettings.BreakableEntity   = EditorGUILayout.ToggleLeft("Breakable objects (func_breakable)", ImportSettings.BreakableEntity);
                            ImportSettings.DoorEntity        = EditorGUILayout.ToggleLeft("Doors (func_door, func_door_rotating)", ImportSettings.DoorEntity);
                            ImportSettings.PlayerSpawns      = EditorGUILayout.ToggleLeft("Player spawns (info_player_deathmatch/start, info_vip_start)", ImportSettings.PlayerSpawns);
                            GUI.enabled = true;
                        }
                    }
                    EditorGUILayout.EndVertical();
                }
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            if (ImportSettings.Model0Layer == ImportSettings.OtherModelLayer)
            {
                EditorGUILayout.HelpBox("It is recommended to use different layers for Model 0 and Other Models.\nOtherwise it may create light bugs or something worse.", MessageType.Warning, true);
            }

            if (ImportSettings.LightMap && ImportSettings.LightEntities && ImportSettings.LightEntitiesEnabled)
            {
                EditorGUILayout.HelpBox("Both Light map import and Light Entities are enabled.\nIt may create light bugs or something worse.", MessageType.Warning, true);
            }

            if (string.IsNullOrEmpty(ImportSettings.SceneName) || !Regex.IsMatch(ImportSettings.SceneName, "^[a-zA-Z0-9_\\\\]+$"))
            {
                EditorGUILayout.HelpBox("Invalid scene name.", MessageType.Error, true);
            }
            else if (EditorSceneManager.GetSceneByName(ImportSettings.SceneName).IsValid())
            {
                EditorGUILayout.HelpBox("Name of scene is already used.", MessageType.Error, true);
            }
            else if (!System.IO.File.Exists(ImportSettings.BspPath))
            {
                EditorGUILayout.HelpBox("Map file does not exist.", MessageType.Error, true);
            }
            else if (!Application.isEditor)
            {
                EditorGUILayout.HelpBox("Availible only in editor.", MessageType.Error, true);
            }
            else if (Application.isPlaying)
            {
                EditorGUILayout.HelpBox("Not availible while playing.", MessageType.Error, true);
            }
            else
            {
                if (GUILayout.Button("Import"))
                {
                    CreateMap(ImportSettings);
                }
            }
        }
        EditorGUILayout.EndScrollView();
    }
コード例 #25
0
    public override void OnInspectorGUI()
    {
        Vector4 v4GUIColor = GUI.contentColor;

        // Update the serializedProperty - always do this in the beginning of OnInspectorGUI.

        serializedObject.Update();

        // Show the custom GUI controls

        bool bResetNodePositions = false;

        bool bDeleteRope             = false;
        bool bRegenerateRope         = false;
        bool bMakeStatic             = false;
        bool bChangeRopeDiameter     = false;
        bool bChangeRopeSegmentSides = false;
        bool bSetupRopeLinks         = false;
        bool bRecomputeCoil          = false;
        bool bSetupRopeJoints        = false;
        bool bSetupRopeMaterials     = false;

        UltimateRope rope = target as UltimateRope;

        bool bIsRopeBreakable = rope.LinkJointBreakForce != Mathf.Infinity || rope.LinkJointBreakTorque != Mathf.Infinity;

        EditorGUILayout.HelpBox(rope.Status == null ? "No status" : rope.Status, rope.IsLastStatusError() ? MessageType.Error : MessageType.Info);

        EditorGUI.BeginChangeCheck();
        PropRopeLayer.intValue = EditorGUILayout.LayerField(new GUIContent("Rope Layer", "Set to a layer for either graphics or collision filtering"), PropRopeLayer.intValue);
        if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
        {
            bSetupRopeLinks = true;
        }

        EditorGUI.BeginChangeCheck();
        PropRopePhysicsMaterial.objectReferenceValue = EditorGUILayout.ObjectField(new GUIContent("Rope Physic Material", "Physic material assigned to the rope"), PropRopePhysicsMaterial.objectReferenceValue, typeof(PhysicMaterial), false);
        if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
        {
            bSetupRopeLinks = true;
        }

        EditorGUILayout.Space();

        EditorGUI.BeginChangeCheck();
        EditorGUILayout.PropertyField(PropRopeType, new GUIContent("Rope Type", "The type of rope to generate"));
        if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
        {
            bRegenerateRope = true;
        }

        if (PropRopeType.enumNames[PropRopeType.enumValueIndex] == UltimateRope.ERopeType.Procedural.ToString())
        {
            EditorGUI.BeginChangeCheck();
            GUI.contentColor = PropRopeStart.objectReferenceValue == null ? Color.red : GUI.contentColor;
            PropRopeStart.objectReferenceValue = EditorGUILayout.ObjectField(new GUIContent("Rope Start", "GameObject where the rope starts"), PropRopeStart.objectReferenceValue, typeof(GameObject), true);
            GUI.contentColor = v4GUIColor;
            if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
            {
                bRegenerateRope = true;
            }

            EditorGUI.BeginChangeCheck();
            PropRopeDiameter.floatValue = EditorGUILayout.FloatField(new GUIContent("Rope Diameter", "Rope's section diameter"), PropRopeDiameter.floatValue);
            if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
            {
                bChangeRopeDiameter = true;

                if (rope.FirstNodeIsCoil())
                {
                    bRecomputeCoil = true;
                }
            }

            EditorGUI.BeginChangeCheck();
            PropRopeDiameterScaleX.floatValue = EditorGUILayout.FloatField(new GUIContent("Diameter ScaleX", "Rope's section diameter x scale. Allows for non circular sections."), PropRopeDiameterScaleX.floatValue);
            if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
            {
                bChangeRopeDiameter = true;
            }

            EditorGUI.BeginChangeCheck();
            PropRopeDiameterScaleY.floatValue = EditorGUILayout.FloatField(new GUIContent("Diameter ScaleY", "Rope's section diameter y scale. Allows for non circular sections."), PropRopeDiameterScaleY.floatValue);
            if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
            {
                bChangeRopeDiameter = true;
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.IntSlider(PropRopeSegmentSides, 3, 128, new GUIContent("Rope Sides", "Set to larger values for rounder rope"));
            if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
            {
                bChangeRopeSegmentSides = true;
            }

            EditorGUI.BeginChangeCheck();
            PropRopeMaterial.objectReferenceValue = EditorGUILayout.ObjectField(new GUIContent("Rope Material", "Material assigned to the rope mesh"), PropRopeMaterial.objectReferenceValue, typeof(Material), false);
            if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
            {
                bSetupRopeMaterials = true;
            }

            EditorGUI.BeginChangeCheck();
            PropRopeSectionMaterial.objectReferenceValue = EditorGUILayout.ObjectField(new GUIContent("Rope Section Material", "Material assigned to the caps and also the inside section of a rope mesh when it breaks"), PropRopeSectionMaterial.objectReferenceValue, typeof(Material), false);
            if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
            {
                bSetupRopeMaterials = true;
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(PropEnablePrefabUsage, new GUIContent("Enable Prefab Usage", "Will save the rope procedural mesh to an asset file on disk. Use this if you want to add this object to a prefab, otherwise the mesh won't be instanced properly."), GUILayout.ExpandWidth(true));
            if (EditorGUI.EndChangeCheck() && PropEnablePrefabUsage.boolValue)
            {
                rope.m_strAssetFile = UnityEditor.EditorUtility.SaveFilePanelInProject("Save mesh asset", "mesh_" + rope.name + this.GetInstanceID().ToString() + ".asset", "asset", "Please enter a file name to save the mesh asset to");

                if (rope.GetComponent <SkinnedMeshRenderer>() != null)
                {
                    if (rope.GetComponent <SkinnedMeshRenderer>().sharedMesh != null)
                    {
                        UnityEditor.AssetDatabase.CreateAsset(rope.GetComponent <SkinnedMeshRenderer>().sharedMesh, rope.m_strAssetFile);
                        UnityEditor.AssetDatabase.ImportAsset(rope.m_strAssetFile);
                        UnityEditor.AssetDatabase.Refresh();
                    }
                }
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(PropIsExtensible, new GUIContent("Is Extensible", "Adds the ability to extend the rope's end through scripting"), GUILayout.ExpandWidth(true));
            if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
            {
                bRegenerateRope = true;
            }

            if (PropIsExtensible.boolValue)
            {
                EditorGUI.BeginChangeCheck();
                PropExtensibleLength.floatValue = EditorGUILayout.FloatField(new GUIContent("Extensible Length", "The additional rope length that can be extended through scripting."), PropExtensibleLength.floatValue);
                if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
                {
                    bRegenerateRope = true;
                }

                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(PropHasACoil, new GUIContent("Has a Coil", "Adds a coil to the extensible rope that can simulate visually from where it is being extended"), GUILayout.ExpandWidth(true));
                if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
                {
                    bRegenerateRope = true;
                }

                if (PropHasACoil.boolValue)
                {
                    EditorGUI.BeginChangeCheck();
                    GUI.contentColor = PropCoilObject.objectReferenceValue == null ? Color.red : GUI.contentColor;
                    PropCoilObject.objectReferenceValue = EditorGUILayout.ObjectField(new GUIContent("Coil Object", "Object around which the coil is placed"), PropCoilObject.objectReferenceValue, typeof(GameObject), true);
                    GUI.contentColor = v4GUIColor;
                    if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
                    {
                        bRegenerateRope = true;
                    }

                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(PropCoilAxisRight, new GUIContent("Coil Axis Right", "The local axis along which the coil is going to twist"));
                    if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
                    {
                        bRegenerateRope = true;
                    }

                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(PropCoilAxisUp, new GUIContent("Coil Axis Up", "The local coil object's axis that looks up"));
                    if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
                    {
                        bRegenerateRope = true;
                    }

                    EditorGUI.BeginChangeCheck();
                    PropCoilWidth.floatValue = EditorGUILayout.FloatField(new GUIContent("Coil Width", "The width of the coil"), PropCoilWidth.floatValue);
                    if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
                    {
                        bRegenerateRope = true;
                    }

                    EditorGUI.BeginChangeCheck();
                    PropCoilDiameter.floatValue = EditorGUILayout.FloatField(new GUIContent("Coil Diameter", "The diameter of the coil"), PropCoilDiameter.floatValue);
                    if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
                    {
                        bRegenerateRope = true;
                    }

                    EditorGUI.BeginChangeCheck();
                    PropCoilNumBones.intValue = EditorGUILayout.IntField(new GUIContent("Coil Bone Count", "The number of bones to use to create the coil"), PropCoilNumBones.intValue, GUILayout.ExpandWidth(true));
                    if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
                    {
                        bRegenerateRope = true;
                    }
                }
            }
        }
        else if (PropRopeType.enumNames[PropRopeType.enumValueIndex] == UltimateRope.ERopeType.LinkedObjects.ToString())
        {
            EditorGUI.BeginChangeCheck();
            GUI.contentColor = PropRopeStart.objectReferenceValue == null ? Color.red : GUI.contentColor;
            PropRopeStart.objectReferenceValue = EditorGUILayout.ObjectField(new GUIContent("Rope Start", "GameObject where the rope starts"), PropRopeStart.objectReferenceValue, typeof(GameObject), true);
            GUI.contentColor = v4GUIColor;
            if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
            {
                bRegenerateRope = true;
            }

            EditorGUI.BeginChangeCheck();
            GUI.contentColor = PropLinkObject.objectReferenceValue == null ? Color.red : GUI.contentColor;
            PropLinkObject.objectReferenceValue = EditorGUILayout.ObjectField(new GUIContent("Link Object", "GameObject to be used as link"), PropLinkObject.objectReferenceValue, typeof(GameObject), true);
            GUI.contentColor = v4GUIColor;
            if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
            {
                bRegenerateRope = true;
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(PropLinkAxis, new GUIContent("Link Axis", "The local axis along which the link object is placed"));
            if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
            {
                bRegenerateRope = true;
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.Slider(PropLinkOffsetObject, -1.0f, 1.0f, new GUIContent("Object Offset", "Offset of each link along its placement axis"));
            if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
            {
                bRegenerateRope = true;
            }

            EditorGUI.BeginChangeCheck();
            PropLinkTwistAngleStart.floatValue = EditorGUILayout.FloatField(new GUIContent("Link Twist Start", "Start twist angle in degrees"), PropLinkTwistAngleStart.floatValue);
            if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
            {
                bRegenerateRope = true;
            }

            EditorGUI.BeginChangeCheck();
            PropLinkTwistAngleIncrement.floatValue = EditorGUILayout.FloatField(new GUIContent("Link Twist Increment", "Increment applied to each link to the twist angle in degrees"), PropLinkTwistAngleIncrement.floatValue);
            if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
            {
                bRegenerateRope = true;
            }
        }
        else if (PropRopeType.enumNames[PropRopeType.enumValueIndex] == UltimateRope.ERopeType.ImportBones.ToString())
        {
            EditorGUI.BeginChangeCheck();
            GUI.contentColor = PropBoneFirst.objectReferenceValue == null ? Color.red : GUI.contentColor;
            PropBoneFirst.objectReferenceValue = EditorGUILayout.ObjectField(new GUIContent("First Bone", "Start rope bone"), PropBoneFirst.objectReferenceValue, typeof(GameObject), true);
            GUI.contentColor = v4GUIColor;
            if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
            {
                bRegenerateRope = true;
            }

            EditorGUI.BeginChangeCheck();
            GUI.contentColor = PropBoneLast.objectReferenceValue == null ? Color.red : GUI.contentColor;
            PropBoneLast.objectReferenceValue = EditorGUILayout.ObjectField(new GUIContent("Last Bone", "End rope bone"), PropBoneLast.objectReferenceValue, typeof(GameObject), true);
            GUI.contentColor = v4GUIColor;
            if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
            {
                bRegenerateRope = true;
            }

            EditorGUI.BeginChangeCheck();
            PropBoneListNamesStatic.stringValue = EditorGUILayout.TextField(new GUIContent("Static Bone List", "Comma-separated indices of the bones that will be position-locked and thus not having rope physics. Ranges are also valid like this example: 0, 1, 3-6, 10"), PropBoneListNamesStatic.stringValue);
            if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
            {
                bRegenerateRope = true;
            }

            EditorGUI.BeginChangeCheck();
            PropBoneListNamesNoColliders.stringValue = EditorGUILayout.TextField(new GUIContent("Ignore Bone Collider List", "Comma-separated indices of the bones that will NOT have a collider. Ranges are also valid like this example: 0, 1, 3-6, 10"), PropBoneListNamesNoColliders.stringValue);
            if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
            {
                bRegenerateRope = true;
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(PropBoneAxis, new GUIContent("Bone Axis", "The local axis along which the bones are placed"));
            if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
            {
                bRegenerateRope = true;
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(PropBoneColliderType, new GUIContent("Bone Collider Type", "The type of collider to generate for the bones"));
            if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
            {
                bSetupRopeLinks = true;
            }

            if (PropBoneColliderType.enumNames[PropBoneColliderType.enumValueIndex] != UltimateRope.EColliderType.None.ToString())
            {
                EditorGUI.BeginChangeCheck();
                PropBoneColliderDiameter.floatValue = EditorGUILayout.FloatField(new GUIContent("Bone Collider Diameter", "Rope's section diameter"), PropBoneColliderDiameter.floatValue);
                if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
                {
                    bSetupRopeLinks = true;
                }

                EditorGUI.BeginChangeCheck();
                EditorGUILayout.IntSlider(PropBoneColliderSkip, 0, 10, new GUIContent("Bone Collider Skip", "Skips collider generation each n links to avoid undesired inter-link collisions and/or speed up collision physics"));
                if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
                {
                    bSetupRopeLinks = true;
                }

                EditorGUI.BeginChangeCheck();
                EditorGUILayout.Slider(PropBoneColliderLength, 0.01f, 5.0f, new GUIContent("Bone Collider Length", "Adjusts the bone collider length"));
                if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
                {
                    bSetupRopeLinks = true;
                }

                EditorGUI.BeginChangeCheck();
                EditorGUILayout.Slider(PropBoneColliderOffset, -1.0f, 1.0f, new GUIContent("Bone Collider Offset", "Adjusts the bone collider position offset"));
                if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
                {
                    bSetupRopeLinks = true;
                }
            }
        }

        EditorGUILayout.Space();

        int nUp   = -1;
        int nDown = -1;
        int nAdd  = -1;
        int nDel  = -1;

        bool bHasRopeNodes = false;

        if (rope.RopeNodes != null)
        {
            if (rope.RopeNodes.Count != 0)
            {
                bHasRopeNodes = true;
            }
        }

        if (bHasRopeNodes == false)
        {
            rope.RopeNodes = new List <UltimateRope.RopeNode>();
            rope.RopeNodes.Add(new UltimateRope.RopeNode());

            if (rope.AutoRegenerate)
            {
                bRegenerateRope = true;
            }
        }

        if (PropRopeType.enumNames[PropRopeType.enumValueIndex] == UltimateRope.ERopeType.Procedural.ToString() || PropRopeType.enumNames[PropRopeType.enumValueIndex] == UltimateRope.ERopeType.LinkedObjects.ToString())
        {
            for (int nNode = 0; nNode < rope.RopeNodes.Count; nNode++)
            {
                if (rope.RopeNodes[nNode].bIsCoil == false)
                {
                    rope.RopeNodes[nNode].bFold = EditorGUILayout.Foldout(rope.RopeNodes[nNode].bFold, "Rope segment " + nNode);

                    if (rope.RopeNodes[nNode].bFold)
                    {
                        int nButtonWidth = 60;

                        bool bUpEnabled   = rope.FirstNodeIsCoil() ? nNode > 1 : nNode > 0;
                        bool bDownEnabled = nNode < rope.RopeNodes.Count - 1;
                        bool bDelEnabled  = rope.FirstNodeIsCoil() ? rope.RopeNodes.Count > 2 : rope.RopeNodes.Count > 1;

                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.LabelField("", GUILayout.Width(40));
                        GUI.enabled = bUpEnabled;
                        if (GUILayout.Button(new GUIContent("Up"), GUILayout.Width(nButtonWidth)))
                        {
                            nUp = nNode;
                        }
                        GUI.enabled = bDownEnabled;
                        if (GUILayout.Button(new GUIContent("Down"), GUILayout.Width(nButtonWidth)))
                        {
                            nDown = nNode;
                        }
                        GUI.enabled = true;
                        if (GUILayout.Button(new GUIContent("Add"), GUILayout.Width(nButtonWidth)))
                        {
                            nAdd = nNode;
                        }
                        GUI.enabled = bDelEnabled;
                        if (GUILayout.Button(new GUIContent("Del"), GUILayout.Width(nButtonWidth)))
                        {
                            nDel = nNode;
                        }
                        GUI.enabled = true;
                        EditorGUILayout.EndHorizontal();

                        EditorGUI.BeginChangeCheck();
                        GUI.contentColor             = rope.RopeNodes[nNode].goNode == null ? Color.red : GUI.contentColor;
                        rope.RopeNodes[nNode].goNode = EditorGUILayout.ObjectField(new GUIContent("    Segment End", "GameObject where the rope segment ends"), rope.RopeNodes[nNode].goNode, typeof(GameObject), true, GUILayout.ExpandWidth(true)) as GameObject;
                        GUI.contentColor             = v4GUIColor;
                        if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
                        {
                            bRegenerateRope = true;
                        }

                        EditorGUI.BeginChangeCheck();
                        rope.RopeNodes[nNode].fLength = EditorGUILayout.FloatField(new GUIContent("    Length", "Length of the rope segment"), rope.RopeNodes[nNode].fLength, GUILayout.ExpandWidth(true));
                        if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
                        {
                            bRegenerateRope = true;
                        }

                        EditorGUI.BeginChangeCheck();
                        rope.RopeNodes[nNode].nNumLinks = EditorGUILayout.IntField(new GUIContent("    Num Links", "The number of links to use to simulate the rope segment."), rope.RopeNodes[nNode].nNumLinks, GUILayout.ExpandWidth(true));
                        if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
                        {
                            bRegenerateRope = true;
                        }

                        EditorGUI.BeginChangeCheck();
                        rope.RopeNodes[nNode].eColliderType = (UltimateRope.EColliderType)EditorGUILayout.EnumPopup(new GUIContent("    Collider Type", "The type of collider to generate for the links, or no colliders"), rope.RopeNodes[nNode].eColliderType, GUILayout.ExpandWidth(true));
                        if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
                        {
                            bSetupRopeLinks = true;
                        }

                        if (rope.RopeNodes[nNode].eColliderType != UltimateRope.EColliderType.None)
                        {
                            EditorGUI.BeginChangeCheck();
                            rope.RopeNodes[nNode].nColliderSkip = EditorGUILayout.IntSlider(new GUIContent("    Link Collider Skip", "Skips collider generation each n links to avoid undesired inter-link collisions and/or speed up collision physics"), rope.RopeNodes[nNode].nColliderSkip, 0, 10);
                            if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
                            {
                                bSetupRopeLinks = true;
                            }
                        }
                    }
                }
            }

            if (nUp != -1)
            {
                rope.MoveNodeUp(nUp);
                if (rope.AutoRegenerate)
                {
                    bRegenerateRope = true;
                }
            }
            else if (nDown != -1)
            {
                rope.MoveNodeDown(nDown);
                if (rope.AutoRegenerate)
                {
                    bRegenerateRope = true;
                }
            }
            else if (nAdd != -1)
            {
                rope.CreateNewNode(nAdd);
                if (rope.AutoRegenerate)
                {
                    bRegenerateRope = true;
                }
            }
            else if (nDel != -1)
            {
                rope.RemoveNode(nDel);
                if (rope.AutoRegenerate)
                {
                    bRegenerateRope = true;
                }
            }

            EditorGUILayout.Space();
        }

        EditorGUI.BeginChangeCheck();
        PropLinkMass.floatValue = EditorGUILayout.FloatField(new GUIContent("Link Mass", "Mass assigned to each link"), PropLinkMass.floatValue);
        if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
        {
            bSetupRopeLinks = true;
        }

        EditorGUI.BeginChangeCheck();
        EditorGUILayout.IntSlider(PropLinkSolverIterationCount, 1, 255, new GUIContent("Link Solver Iterations", "Set to larger values for more physic steps at the cost of more computational power"));
        if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
        {
            bSetupRopeLinks = true;
        }

        EditorGUI.BeginChangeCheck();
        EditorGUILayout.Slider(PropLinkJointAngularXLimit, 0.0f, 180.0f, new GUIContent("Link Joint Angular X Limit", "Angular limit for link joints in the x asis"));
        if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
        {
            bSetupRopeJoints = true;
        }

        EditorGUI.BeginChangeCheck();
        EditorGUILayout.Slider(PropLinkJointAngularYLimit, 0.0f, 180.0f, new GUIContent("Link Joint Angular Y Limit", "Angular limit for link joints in the y asis"));
        if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
        {
            bSetupRopeJoints = true;
        }

        EditorGUI.BeginChangeCheck();
        EditorGUILayout.Slider(PropLinkJointAngularZLimit, 0.0f, 180.0f, new GUIContent("Link Joint Angular Z Limit", "Angular limit for link joints in the z asis"));
        if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
        {
            bSetupRopeJoints = true;
        }

        EditorGUI.BeginChangeCheck();
        PropLinkJointSpringValue.floatValue = EditorGUILayout.FloatField(new GUIContent("Link Joint Spring", "Spring value assigned to each link joint"), PropLinkJointSpringValue.floatValue);
        if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
        {
            bSetupRopeJoints = true;
        }

        EditorGUI.BeginChangeCheck();
        PropLinkJointDamperValue.floatValue = EditorGUILayout.FloatField(new GUIContent("Link Joint Damper", "Damper value assigned to each link joint"), PropLinkJointDamperValue.floatValue);
        if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
        {
            bSetupRopeJoints = true;
        }

        EditorGUI.BeginChangeCheck();
        PropLinkJointMaxForceValue.floatValue = EditorGUILayout.FloatField(new GUIContent("Link Joint Max Force", "Max Force value assigned to each link joint"), PropLinkJointMaxForceValue.floatValue);
        if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
        {
            bSetupRopeJoints = true;
        }

        EditorGUI.BeginChangeCheck();
        PropLinkJointBreakForce.floatValue = EditorGUILayout.FloatField(new GUIContent("Link Joint Break Force", "Force needed to break a link joint (Infinity for non breakable)"), PropLinkJointBreakForce.floatValue);
        if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
        {
            bSetupRopeJoints = true;
        }

        EditorGUI.BeginChangeCheck();
        PropLinkJointBreakTorque.floatValue = EditorGUILayout.FloatField(new GUIContent("Link Joint Break Torque", "Torque needed to break a link joint (Infinity for non breakable)"), PropLinkJointBreakTorque.floatValue);
        if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
        {
            bSetupRopeJoints = true;
        }

        bool bIsRopeBreakableNow = PropLinkJointBreakTorque.floatValue != Mathf.Infinity || PropLinkJointBreakForce.floatValue != Mathf.Infinity;

        if (bIsRopeBreakable != bIsRopeBreakableNow)
        {
            bChangeRopeSegmentSides = true; // Changing rope segment sides forces a new mesh
        }

        if (PropRopeType.enumNames[PropRopeType.enumValueIndex] == UltimateRope.ERopeType.Procedural.ToString())
        {
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(PropLockStartEndInZAxis, new GUIContent("Lock Start/End ZAxis", "For each segment, makes the first link and last link to mantain fixed position (they will be aligned in the Z-Axis of each start/end node)"), GUILayout.ExpandWidth(true));
            if (EditorGUI.EndChangeCheck() && rope.AutoRegenerate)
            {
                bRegenerateRope = true;
            }
        }

        EditorGUILayout.Space();

        EditorGUILayout.PropertyField(PropSendEvents, new GUIContent("Send Rope Events", "Send event messages?"), GUILayout.ExpandWidth(true));

        if (PropSendEvents.boolValue)
        {
            EditorGUILayout.PropertyField(PropEventsObjectReceiver, new GUIContent("Events Object Receiver", "GameObject whose methods will be called when events are triggered"), GUILayout.ExpandWidth(true));
            EditorGUILayout.PropertyField(PropOnBreakMethodName, new GUIContent("Break Event Method", "Name of the method that will be called when a rope link breaks"), GUILayout.ExpandWidth(true));
        }

        EditorGUILayout.Space();

        EditorGUILayout.PropertyField(PropPersistAfterPlayMode, new GUIContent("Persist after playmode", "Should the rope component keep its state after exiting playmode?"), GUILayout.ExpandWidth(true));

/*
 *      EditorGUI.BeginChangeCheck();
 *      EditorGUILayout.PropertyField(PropAutoRegenerate, new GUIContent("Auto regenerate", "Should the rope be regenerated automatically after editor changes?"), GUILayout.ExpandWidth(true));
 *      if(EditorGUI.EndChangeCheck() && PropAutoRegenerate.boolValue)
 *      {
 *          bRegenerateRope = true;
 *      }
 */
        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button(new GUIContent("Reset rope")))
        {
            bRegenerateRope     = true;
            bResetNodePositions = rope.HasDynamicSegmentNodes();
        }

        if (GUILayout.Button(new GUIContent("Delete rope")))
        {
            bDeleteRope = true;
        }

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();

        if (GUILayout.Button(new GUIContent("Convert to static mesh")))
        {
            bMakeStatic = true;
        }

        // Apply changes to the serializedProperty

        serializedObject.ApplyModifiedProperties();

        // Perform action at the end

        if (bDeleteRope)
        {
            rope.DeleteRope();
        }

        if (bRegenerateRope)
        {
            rope.Regenerate(bResetNodePositions);
        }
        else
        {
            if (bChangeRopeDiameter)
            {
                rope.ChangeRopeDiameter(PropRopeDiameter.floatValue, PropRopeDiameterScaleX.floatValue, PropRopeDiameterScaleY.floatValue);
            }

            if (bChangeRopeSegmentSides)
            {
                rope.ChangeRopeSegmentSides(PropRopeSegmentSides.intValue);
            }

            if (bSetupRopeLinks)
            {
                rope.SetupRopeLinks();
            }

            if (bSetupRopeMaterials)
            {
                rope.SetupRopeMaterials();
            }

            if (bSetupRopeJoints)
            {
                rope.SetupRopeJoints();
            }

            if (bRecomputeCoil)
            {
                rope.RecomputeCoil();
            }
        }

        if (bMakeStatic)
        {
            if (Application.isPlaying)
            {
                EditorUtility.DisplayDialog("Error", "Rope can't be made static from within the play mode, please use edit mode instead. Current rope state can be saved using the Persist After Playmode checkbox if needed.", "OK");
            }
            else if (EditorUtility.DisplayDialog("Are you sure?", "A new static GameObject will be created and the current will be hidden but not deleted in case the result is not satisfactory. To unhide it use the checkbox left to the name in the inspector.\nFor some ropes it will take some time to create the static object, since lightmapping coordinates will be computed if the object doesn't have them.", "Make static", "Cancel") == true)
            {
                string strStatus;

                GameObject newObject = rope.BuildStaticMeshObject(out strStatus);

                if (newObject == null)
                {
                    EditorUtility.DisplayDialog("Error", strStatus, "OK");
                }
                else
                {
                    UnityEditor.Selection.activeGameObject = newObject;
                }
            }
        }
    }
コード例 #26
0
    public override void OnInspectorGUI()
    {
        //base.OnInspectorGUI();
        particleCanvas = (UIParticleCanvas)target;

        if (particleCanvas)
        {
            EditorGUI.BeginChangeCheck();

            particleCanvas.maskResolutionScale = EditorGUILayout.Slider("Mask resolution scale", particleCanvas.maskResolutionScale, 0.05f, 1f);
            particleCanvas.maskLayer           = EditorGUILayout.LayerField("Mask layer", particleCanvas.maskLayer);
            if (particleCanvas.Canvas.worldCamera == null)
            {
                EditorGUILayout.HelpBox("Attach camera to GUI Canvas!", MessageType.Error);
            }
            else
            {
                bool layerIsInCulling = particleCanvas.Canvas.worldCamera.cullingMask == (particleCanvas.Canvas.worldCamera.cullingMask | (1 << particleCanvas.maskLayer));
                if (layerIsInCulling)
                {
                    EditorGUILayout.HelpBox("Mask layer shouldn't be the same as layer rendered by GUI camera, change the mask layer or change culling mask in GUI camera", MessageType.Error);
                }
            }

            if (EditorGUI.EndChangeCheck())
            {
                particleCanvas.enabled = false;
                particleCanvas.SetToReinitialize();
                particleCanvas.enabled = true;
                if (!Application.isPlaying)
                {
                    EditorUtility.SetDirty(particleCanvas);
                    if (particleCanvas.gameObject.scene.IsValid())
                    {
                        EditorSceneManager.MarkSceneDirty(particleCanvas.gameObject.scene);
                    }
                }
            }

            if (particleCanvas.Mask != null && (debugMask = EditorGUILayout.Foldout(debugMask, "Show depth mask")))
            {
                Rect texRect = GUILayoutUtility.GetAspectRect((float)particleCanvas.Mask.width / particleCanvas.Mask.height);
                EditorGUI.DrawPreviewTexture(texRect, particleCanvas.Mask);
            }

            if (particleCanvas.Mask != null && (debugCullMask = EditorGUILayout.Foldout(debugCullMask, "Show culling mask")))
            {
                Rect texRect = GUILayoutUtility.GetAspectRect((float)particleCanvas.Mask.width / particleCanvas.Mask.height);
                EditorGUI.DrawTextureAlpha(texRect, particleCanvas.Mask);
            }

            if (GUILayout.Button("Refresh"))
            {
                particleCanvas.enabled = false;
                particleCanvas.SetToReinitialize();
                particleCanvas.enabled = true;
            }

            if (particleCanvas.EditorErrorLog != null && particleCanvas.EditorErrorLog.Length > 0)
            {
                EditorGUILayout.HelpBox(particleCanvas.EditorErrorLog, MessageType.Error);
            }
        }
    }
コード例 #27
0
        private void DrawTabAdvanced()
        {
            _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition, false, true);

            GUILayout.Label("Console", SRDebugEditorUtil.Styles.InspectorHeaderStyle);

            Settings.Instance.CollapseDuplicateLogEntries =
                EditorGUILayout.Toggle(
                    new GUIContent("Collapse Log Entries", "Collapse duplicate log entries into single log."),
                    Settings.Instance.CollapseDuplicateLogEntries);

            Settings.Instance.RichTextInConsole =
                EditorGUILayout.Toggle(
                    new GUIContent("Rich Text in Console", "Parse rich text tags in console log entries."),
                    Settings.Instance.RichTextInConsole);

            Settings.Instance.MaximumConsoleEntries =
                EditorGUILayout.IntSlider(
                    new GUIContent("Max Console Entries",
                                   "The maximum size of the console buffer. Higher values may cause performance issues on slower devices."),
                    Settings.Instance.MaximumConsoleEntries, 100, 6000);

            EditorGUILayout.Separator();
            GUILayout.Label("Display", SRDebugEditorUtil.Styles.InspectorHeaderStyle);

            Settings.Instance.EnableBackgroundTransparency =
                EditorGUILayout.Toggle(new GUIContent("Transparent Background"),
                                       Settings.Instance.EnableBackgroundTransparency);

            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.PrefixLabel(new GUIContent("Layer", "The layer the debug panel UI will be drawn to"));

            Settings.Instance.DebugLayer = EditorGUILayout.LayerField(Settings.Instance.DebugLayer);

            EditorGUILayout.EndHorizontal();

            Settings.Instance.UseDebugCamera =
                EditorGUILayout.Toggle(
                    new GUIContent("Use Debug Camera", SRDebugStrings.Current.SettingsDebugCameraTooltip),
                    Settings.Instance.UseDebugCamera);

            EditorGUI.BeginDisabledGroup(!Settings.Instance.UseDebugCamera);

            Settings.Instance.DebugCameraDepth = EditorGUILayout.Slider(new GUIContent("Debug Camera Depth"),
                                                                        Settings.Instance.DebugCameraDepth, -100, 100);

            EditorGUI.EndDisabledGroup();

            Settings.Instance.UIScale =
                EditorGUILayout.Slider(new GUIContent("UI Scale"), Settings.Instance.UIScale, 1f, 3f);

            EditorGUILayout.Separator();
            GUILayout.Label("Enabled Tabs", SRDebugEditorUtil.Styles.InspectorHeaderStyle);

            GUILayout.Label(SRDebugStrings.Current.SettingsEnabledTabsDescription, EditorStyles.wordWrappedLabel);
            EditorGUILayout.Space();

            var disabledTabs = Settings.Instance.DisabledTabs.ToList();

            var tabNames  = Enum.GetNames(typeof(DefaultTabs));
            var tabValues = Enum.GetValues(typeof(DefaultTabs));

            EditorGUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins);

            var changed = false;

            for (var i = 0; i < tabNames.Length; i++)
            {
                var tabName  = tabNames[i];
                var tabValue = (DefaultTabs)(tabValues.GetValue(i));

                if (tabName == "BugReporter")
                {
                    continue;
                }

                if (tabName == "SystemInformation")
                {
                    tabName = "System Information";
                }

                EditorGUILayout.BeginHorizontal();

                var isEnabled = !disabledTabs.Contains(tabValue);

                var isNowEnabled = EditorGUILayout.ToggleLeft(tabName, isEnabled,
                                                              SRDebugEditorUtil.Styles.LeftToggleButton);

                if (isEnabled && !isNowEnabled)
                {
                    disabledTabs.Add(tabValue);
                    changed = true;
                }
                else if (!isEnabled && isNowEnabled)
                {
                    disabledTabs.Remove(tabValue);
                    changed = true;
                }

                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.EndVertical();

            if (changed)
            {
                Settings.Instance.DisabledTabs = disabledTabs;
            }

            GUILayout.Label("Other", SRDebugEditorUtil.Styles.InspectorHeaderStyle);

            Settings.Instance.EnableEventSystemGeneration =
                EditorGUILayout.Toggle(
                    new GUIContent("Automatic Event System", "Automatically create a UGUI EventSystem if none is found in the scene."),
                    Settings.Instance.EnableEventSystemGeneration);

            EditorGUILayout.Separator();

            if (GUILayout.Button("Run Migrations"))
            {
                Migrations.RunMigrations(true);
            }

            EditorGUILayout.EndScrollView();
        }
コード例 #28
0
    public override void OnInspectorGUI()
    {
        ARController arcontroller = (ARController)target;

        if (arcontroller == null)
        {
            return;
        }


        EditorGUILayout.LabelField("Version", "ARToolKit " + arcontroller.Version);


        EditorGUILayout.Separator();

        showVideoOptions = EditorGUILayout.Foldout(showVideoOptions, "Video Options");
        if (showVideoOptions)
        {
            arcontroller.videoCParamName0                = EditorGUILayout.TextField("Camera parameters", arcontroller.videoCParamName0);
            arcontroller.videoConfigurationWindows0      = EditorGUILayout.TextField("Video config. (Windows)", arcontroller.videoConfigurationWindows0);
            arcontroller.videoConfigurationMacOSX0       = EditorGUILayout.TextField("Video config. (Mac OS X)", arcontroller.videoConfigurationMacOSX0);
            arcontroller.videoConfigurationiOS0          = EditorGUILayout.TextField("Video config. (iOS)", arcontroller.videoConfigurationiOS0);
            arcontroller.videoConfigurationAndroid0      = EditorGUILayout.TextField("Video config. (Android)", arcontroller.videoConfigurationAndroid0);
            arcontroller.videoConfigurationWindowsStore0 = EditorGUILayout.TextField("Video config. (Windows Store)", arcontroller.videoConfigurationWindowsStore0);
            arcontroller.videoConfigurationLinux0        = EditorGUILayout.TextField("Video config. (Linux)", arcontroller.videoConfigurationLinux0);
            arcontroller.BackgroundLayer0                = EditorGUILayout.LayerField("Layer", arcontroller.BackgroundLayer0);

            arcontroller.VideoIsStereo = EditorGUILayout.Toggle("Video source is stereo", arcontroller.VideoIsStereo);
            if (arcontroller.VideoIsStereo)
            {
                arcontroller.videoCParamName1                = EditorGUILayout.TextField("Camera parameters (R)", arcontroller.videoCParamName1);
                arcontroller.videoConfigurationWindows1      = EditorGUILayout.TextField("Video config.(R) (Windows)", arcontroller.videoConfigurationWindows1);
                arcontroller.videoConfigurationMacOSX1       = EditorGUILayout.TextField("Video config.(R) (Mac OS X)", arcontroller.videoConfigurationMacOSX1);
                arcontroller.videoConfigurationiOS1          = EditorGUILayout.TextField("Video config.(R) (iOS)", arcontroller.videoConfigurationiOS1);
                arcontroller.videoConfigurationAndroid1      = EditorGUILayout.TextField("Video config.(R) (Android)", arcontroller.videoConfigurationAndroid1);
                arcontroller.videoConfigurationWindowsStore1 = EditorGUILayout.TextField("Video config.(R) (Windows Store)", arcontroller.videoConfigurationWindowsStore1);
                arcontroller.videoConfigurationLinux1        = EditorGUILayout.TextField("Video config. (Linux)", arcontroller.videoConfigurationLinux1);
                arcontroller.BackgroundLayer1                = EditorGUILayout.LayerField("Layer (R)", arcontroller.BackgroundLayer1);
                arcontroller.transL2RName = EditorGUILayout.TextField("Stereo parameters", arcontroller.transL2RName);
            }


            arcontroller.UseNativeGLTexturingIfAvailable = EditorGUILayout.Toggle("Use native GL texturing (if available)", arcontroller.UseNativeGLTexturingIfAvailable);
            if (arcontroller.UseNativeGLTexturingIfAvailable)
            {
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.Toggle("Allow non-RGB video internally.", false);
                EditorGUI.EndDisabledGroup();
            }
            else
            {
                arcontroller.AllowNonRGBVideo = EditorGUILayout.Toggle("Allow non-RGB video internally.", arcontroller.AllowNonRGBVideo);
            }


            ContentMode currentContentMode = arcontroller.ContentMode;
            ContentMode newContentMode     = (ContentMode)EditorGUILayout.EnumPopup("Content mode", currentContentMode);
            if (newContentMode != currentContentMode)
            {
                arcontroller.ContentMode = newContentMode;
            }
            arcontroller.ContentRotate90 = EditorGUILayout.Toggle("Rotate 90 deg.", arcontroller.ContentRotate90);
            arcontroller.ContentFlipV    = EditorGUILayout.Toggle("Flip vertically", arcontroller.ContentFlipV);
            arcontroller.ContentFlipH    = EditorGUILayout.Toggle("Flip horizontally.", arcontroller.ContentFlipH);

            arcontroller.myCamera = (Camera)EditorGUILayout.ObjectField(arcontroller.myCamera, typeof(Camera), true);

            arcontroller.webcamPlane = (GameObject)EditorGUILayout.ObjectField(arcontroller.webcamPlane, typeof(GameObject), true);
        }

        EditorGUILayout.Separator();

        arcontroller.NearPlane = EditorGUILayout.FloatField("Near plane", arcontroller.NearPlane);
        arcontroller.FarPlane  = EditorGUILayout.FloatField("Far plane", arcontroller.FarPlane);

        EditorGUILayout.Separator();

        showThresholdOptions = EditorGUILayout.Foldout(showThresholdOptions, "Threshold Options");
        if (showThresholdOptions)
        {
            // Threshold mode selection
            ARController.ARToolKitThresholdMode currentThreshMode = arcontroller.VideoThresholdMode;
            ARController.ARToolKitThresholdMode newThreshMode     = (ARController.ARToolKitThresholdMode)EditorGUILayout.EnumPopup("Mode:", currentThreshMode);
            if (newThreshMode != currentThreshMode)
            {
                arcontroller.VideoThresholdMode = newThreshMode;
            }

            // Info about the selected mode
            EditorGUILayout.LabelField("", ARController.ThresholdModeDescriptions[newThreshMode]);

            // Show threshold slider only in manual or bracketing modes.
            if (newThreshMode == ARController.ARToolKitThresholdMode.Manual || newThreshMode == ARController.ARToolKitThresholdMode.Bracketing)
            {
                int currentThreshold = arcontroller.VideoThreshold;
                //int newThreshold = UnityEngine.Mathf.Clamp(EditorGUILayout.IntField("Threshold: ", currentThreshold), 0, 255);
                int newThreshold = EditorGUILayout.IntSlider("Threshold: ", currentThreshold, 0, 255);
                if (newThreshold != currentThreshold)
                {
                    arcontroller.VideoThreshold = newThreshold;
                }
            }
        }

        EditorGUILayout.Separator();

        showSquareTrackingOptions = EditorGUILayout.Foldout(showSquareTrackingOptions, "Square Tracking Options");
        if (showSquareTrackingOptions)
        {
            int currentTemplateSize = arcontroller.TemplateSize;
            int newTemplateSize     = EditorGUILayout.IntField("Template size: ", currentTemplateSize);
            if (newTemplateSize != currentTemplateSize && newTemplateSize >= 16 && newTemplateSize <= 64)
            {
                arcontroller.TemplateSize = newTemplateSize;
            }
            int currentTemplateCountMax = arcontroller.TemplateCountMax;
            int newTemplateCountMax     = EditorGUILayout.IntField("Template count max.: ", currentTemplateCountMax);
            if (newTemplateCountMax != currentTemplateCountMax && newTemplateCountMax > 0)
            {
                arcontroller.TemplateCountMax = newTemplateCountMax;
            }

            // Labeling mode selection.
            ARController.ARToolKitLabelingMode currentLabelingMode = arcontroller.LabelingMode;
            ARController.ARToolKitLabelingMode newLabelingMode     = (ARController.ARToolKitLabelingMode)EditorGUILayout.EnumPopup("Marker borders:", currentLabelingMode);
            if (newLabelingMode != currentLabelingMode)
            {
                arcontroller.LabelingMode = newLabelingMode;
            }

            // Border size selection.
            float currentBorderSize = arcontroller.BorderSize;
            float newBorderSize     = UnityEngine.Mathf.Clamp(EditorGUILayout.FloatField("Border size:", currentBorderSize), 0.0f, 0.5f);
            if (newBorderSize != currentBorderSize)
            {
                arcontroller.BorderSize = newBorderSize;
            }

            // Pattern detection mode selection.
            ARController.ARToolKitPatternDetectionMode currentPatternDetectionMode = arcontroller.PatternDetectionMode;
            ARController.ARToolKitPatternDetectionMode newPatternDetectionMode     = (ARController.ARToolKitPatternDetectionMode)EditorGUILayout.EnumPopup("Pattern detection mode:", currentPatternDetectionMode);
            if (newPatternDetectionMode != currentPatternDetectionMode)
            {
                arcontroller.PatternDetectionMode = newPatternDetectionMode;
            }

            // Matrix code type selection (only when in one of the matrix modes).
            if (newPatternDetectionMode == ARController.ARToolKitPatternDetectionMode.AR_MATRIX_CODE_DETECTION ||
                newPatternDetectionMode == ARController.ARToolKitPatternDetectionMode.AR_TEMPLATE_MATCHING_COLOR_AND_MATRIX ||
                newPatternDetectionMode == ARController.ARToolKitPatternDetectionMode.AR_TEMPLATE_MATCHING_MONO_AND_MATRIX)
            {
                ARController.ARToolKitMatrixCodeType currentMatrixCodeType = arcontroller.MatrixCodeType;
                ARController.ARToolKitMatrixCodeType newMatrixCodeType     = (ARController.ARToolKitMatrixCodeType)EditorGUILayout.EnumPopup("Matrix code type:", currentMatrixCodeType);
                if (newMatrixCodeType != currentMatrixCodeType)
                {
                    arcontroller.MatrixCodeType = newMatrixCodeType;
                }
            }

            // Image processing mode selection.
            ARController.ARToolKitImageProcMode currentImageProcMode = arcontroller.ImageProcMode;
            ARController.ARToolKitImageProcMode newImageProcMode     = (ARController.ARToolKitImageProcMode)EditorGUILayout.EnumPopup("Image processing mode:", currentImageProcMode);
            if (newImageProcMode != currentImageProcMode)
            {
                arcontroller.ImageProcMode = newImageProcMode;
            }
        }

        EditorGUILayout.Separator();

        showNFTTrackingOptions = EditorGUILayout.Foldout(showNFTTrackingOptions, "NFT Tracking Options");
        if (showNFTTrackingOptions)
        {
            arcontroller.NFTMultiMode = EditorGUILayout.Toggle("Multi-page mode", arcontroller.NFTMultiMode);
        }

        EditorGUILayout.Separator();
        showApplicationOptions = EditorGUILayout.Foldout(showApplicationOptions, "Application Options");
        if (showApplicationOptions)
        {
            arcontroller.AutoStartAR = EditorGUILayout.Toggle("Auto-start AR.", arcontroller.AutoStartAR);
            if (arcontroller.AutoStartAR)
            {
                EditorGUILayout.HelpBox("ARController.StartAR() will be called during MonoBehavior.Start().", MessageType.Info);
            }
            else
            {
                EditorGUILayout.HelpBox("ARController.StartAR() will not be called during MonoBehavior.Start(); you must call it yourself.", MessageType.Info);
            }
            arcontroller.QuitOnEscOrBack = EditorGUILayout.Toggle("Quit on [Esc].", arcontroller.QuitOnEscOrBack);
            if (arcontroller.QuitOnEscOrBack)
            {
                EditorGUILayout.HelpBox("The [esc] key (Windows, OS X) or the [Back] button (Android) will quit the app.", MessageType.Info);
            }
            else
            {
                EditorGUILayout.HelpBox("The [esc] key (Windows, OS X) or the [Back] button (Android) will be ignored.", MessageType.Info);
            }
            arcontroller.LogLevel = (ARController.AR_LOG_LEVEL)EditorGUILayout.EnumPopup("Log level:", arcontroller.LogLevel);
        }
    }
コード例 #29
0
        public static void PreferencesGUI()
        {
            scroll = EditorGUILayout.BeginScrollView(scroll);
            CurvyGlobalManager.DefaultInterpolation = (CurvyInterpolation)EditorGUILayout.EnumPopup("Default Spline Type", CurvyGlobalManager.DefaultInterpolation);
            Instance.SnapValuePrecision             = EditorGUILayout.Toggle(new GUIContent("Snap Value Precision", "Round inspector values"), Instance.SnapValuePrecision);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.TextField(new GUIContent("Customization Root Path", "Base Path for custom Curvy extensions"), Instance.CustomizationRootPath);
            if (GUILayout.Button(new GUIContent("<", "Select"), GUILayout.ExpandWidth(false)))
            {
                string path = EditorUtility.OpenFolderPanel("Customization Root Path", Application.dataPath, "");
                if (!string.IsNullOrEmpty(path))
                {
                    Instance.CustomizationRootPath = path.Replace(Application.dataPath + "/", "");
                }
            }
            EditorGUILayout.EndHorizontal();
            CurvyGlobalManager.MaxCachePPU         = Mathf.Max(1, EditorGUILayout.IntField(new GUIContent("Max Cache PPU", "Max cached points per World Unit"), CurvyGlobalManager.MaxCachePPU));
            CurvyGlobalManager.SceneViewResolution = EditorGUILayout.Slider(new GUIContent("SceneView Resolution", "Lower values results in faster SceneView drawing"), CurvyGlobalManager.SceneViewResolution, 0, 1);
            CurvyGlobalManager.HideManager         = EditorGUILayout.Toggle(new GUIContent("Hide _CurvyGlobal_", "Hide the global manager in Hierarchy?"), CurvyGlobalManager.HideManager);
            foldouts[0] = EditorGUILayout.Foldout(foldouts[0], "Editor", CurvyStyles.Foldout);
            if (foldouts[0])
            {
                CurvyGlobalManager.DefaultGizmoColor          = EditorGUILayout.ColorField("Spline color", CurvyGlobalManager.DefaultGizmoColor);
                CurvyGlobalManager.DefaultGizmoSelectionColor = EditorGUILayout.ColorField("Spline Selection color", CurvyGlobalManager.DefaultGizmoSelectionColor);
                CurvyGlobalManager.GizmoControlPointSize      = EditorGUILayout.FloatField("Control Point Size", CurvyGlobalManager.GizmoControlPointSize);
                CurvyGlobalManager.GizmoOrientationLength     = EditorGUILayout.FloatField(new GUIContent("Orientation Length", "Orientation gizmo size"), CurvyGlobalManager.GizmoOrientationLength);
                CurvyGlobalManager.GizmoOrientationColor      = EditorGUILayout.ColorField(new GUIContent("Orientation Color", "Orientation gizmo color"), CurvyGlobalManager.GizmoOrientationColor);
                Instance.UseTiny2DHandles      = EditorGUILayout.Toggle("Use tiny 2D handles", Instance.UseTiny2DHandles);
                CurvyGlobalManager.SplineLayer = EditorGUILayout.LayerField(new GUIContent("Default Spline Layer", "Layer to use for splines and Control Points"), CurvyGlobalManager.SplineLayer);
            }
            foldouts[1] = EditorGUILayout.Foldout(foldouts[1], "UI", CurvyStyles.Foldout);
            if (foldouts[1])
            {
                Instance.ShowGlobalToolbar  = EditorGUILayout.Toggle(new GUIContent("Show Global Toolbar", "Always show Curvy Toolbar"), Instance.ShowGlobalToolbar);
                Instance.ToolbarMode        = (DTToolbarMode)EditorGUILayout.EnumPopup(new GUIContent("Toolbar Labels", "Defines Toolbar Display Mode"), Instance.ToolbarMode);
                Instance.ToolbarOrientation = (DTToolbarOrientation)EditorGUILayout.EnumPopup(new GUIContent("Toolbar Orientation", "Defines Toolbar Position"), Instance.ToolbarOrientation);
            }

            foldouts[2] = EditorGUILayout.Foldout(foldouts[2], "Shortcuts", CurvyStyles.Foldout);
            if (foldouts[2])
            {
                var keys = Instance.GetProjectBindings();
                foreach (var binding in keys)
                {
                    if (binding.OnPreferencesGUI()) // save changed bindings
                    {
                        Instance.SetEditorPrefs <string>(binding.Name, binding.ToPrefsString());
                    }
                    GUILayout.Space(2);
                    GUILayout.Box("", GUILayout.Height(1), GUILayout.ExpandWidth(true));
                    GUILayout.Space(2);
                }
            }
            if (GUILayout.Button("Reset to defaults"))
            {
                Instance.ResetPreferences();
            }

            EditorGUILayout.EndScrollView();

            if (GUI.changed)
            {
                Instance.SavePreferences();
                DT.ReInitialize(false);
            }
        }
コード例 #30
0
    /// <summary>
    /// 绘制窗口
    /// </summary>
    public void OnGUI()
    {
        if (GUILayout.Button("关闭"))
        {//关闭按钮
            Close();
        }
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("显示通知"))
        {
            GUIContent content = new GUIContent();
            content.text    = "通知";
            content.tooltip = "ShowNotification";
            ShowNotification(new GUIContent(content));
        }
        if (GUILayout.Button("关闭通知"))
        {
            RemoveNotification();
        }
        EditorGUILayout.EndHorizontal();

        //滚动视图分组↓
        scrollViewPos = EditorGUILayout.BeginScrollView(scrollViewPos);

        //Label
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("文本");
        EditorGUILayout.SelectableLabel("可选文本");
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();

        //水平分组↓
        EditorGUILayout.BeginHorizontal();
        //数值输入
        intField   = EditorGUILayout.IntField("整数", intField);
        floatField = EditorGUILayout.FloatField("浮点数", floatField);
        EditorGUILayout.EndHorizontal();
        //水平分组↑

        EditorGUILayout.Space();

        //文本输入
        EditorGUILayout.BeginHorizontal();
        textField     = EditorGUILayout.TextField("文本输入框", textField);
        passwordField = EditorGUILayout.PasswordField("密码输入框", passwordField);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("可换行的文本输入框");
        textArea = EditorGUILayout.TextArea(textArea);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();

        //颜色
        colorField = EditorGUILayout.ColorField("取色器", colorField);

        EditorGUILayout.Space();

        //垂直分组
        EditorGUILayout.BeginVertical();
        //滑动条
        sliderVal = EditorGUILayout.Slider("浮点数滚动条", sliderVal, 0, 1);
        intSlider = EditorGUILayout.IntSlider("整数滚动条", intSlider, 0, 10);
        EditorGUILayout.MinMaxSlider("区间滚动条", ref v2MinMax.x, ref v2MinMax.y, 0, 1);
        EditorGUILayout.EndVertical();

        EditorGUILayout.Space();

        //多元数
        vector2Field = EditorGUILayout.Vector2Field("二维向量", vector2Field);
        vector3Field = EditorGUILayout.Vector3Field("三维向量", vector3Field);
        vector4Field = EditorGUILayout.Vector4Field("四维向量", vector4Field);
        rectField    = EditorGUILayout.RectField("矩形", rectField);
        boundsField  = EditorGUILayout.BoundsField("边界", boundsField);

        EditorGUILayout.Space();

        //下拉列表
        popupVal     = EditorGUILayout.Popup("返回选项数组下标", popupVal, new string[] { "A", "B" });
        intPopupVal  = EditorGUILayout.IntPopup("返回选项数组下标对应的整数数组值", intPopupVal, new string[] { "A", "B" }, new int[] { 1, 2 });
        enumPopupVal = (Condition)EditorGUILayout.EnumPopup("返回枚举", enumPopupVal);

        EditorGUILayout.Space();

        //
        tagField   = EditorGUILayout.TagField("TagField", tagField);
        layerField = EditorGUILayout.LayerField("LayerField", layerField);

        EditorGUILayout.Space();

        foldout = EditorGUILayout.Foldout(foldout, "折叠");
        if (foldout)
        {
            EditorGUILayout.LabelField("折叠内容1");
            EditorGUILayout.LabelField("折叠内容2");
        }

        EditorGUILayout.Space();

        toggle = EditorGUILayout.Toggle("复选框", toggle);

        EditorGUILayout.Space();

        //启用/禁用分组中的内容
        toggleGroup = EditorGUILayout.BeginToggleGroup("启用/禁用分组中的内容", toggleGroup);
        EditorGUILayout.TextField("sdk");
        EditorGUILayout.EndToggleGroup();

        EditorGUILayout.Space();

        curveField        = EditorGUILayout.CurveField("动画片段", curveField);
        inspectorTitlebar = EditorGUILayout.InspectorTitlebar(inspectorTitlebar, objectField);    //将选择的物体放在面板上
        objectField       = EditorGUILayout.ObjectField("ObjectField", objectField, typeof(RectTransform), true);

        EditorGUILayout.EndScrollView();
        //滚动视图分组↑

        #region Mask
        //_enumValue0 = (EnumValue0)EditorGUILayout.EnumMaskField("EnumMaskField", _enumValue0);
        //EditorGUILayout.EnumMaskPopup();
        _enumCustom = (EnumCustom)EditorGUILayout.EnumFlagsField(_enumCustom);
        #endregion
    }