Пример #1
0
    int BoolField(SerializedProperty sp, InspectorPlusVar v)
    {
        if (v.toggleStart)
        {
            EditorGUI.BeginProperty(new Rect(0.0f, 0.0f, 0.0f, 0.0f), new GUIContent(), sp);

            EditorGUI.BeginChangeCheck();
            var newValue = EditorGUILayout.Toggle(dispName, sp.boolValue);

            if (EditorGUI.EndChangeCheck())
            {
                sp.boolValue = newValue;
            }

            EditorGUI.EndProperty();

            if (!sp.boolValue)
            {
                return(v.toggleSize);
            }
        }
        else
        {
            EditorGUILayout.PropertyField(sp, new GUIContent(dispName));
        }

        return(0);
    }
Пример #2
0
    void IntField(SerializedProperty sp, InspectorPlusVar v)
    {
        if (v.limitType == InspectorPlusVar.LimitType.Min && !sp.hasMultipleDifferentValues)
        {
            sp.intValue = Mathf.Max(v.iMin, sp.intValue);
        }
        else if (v.limitType == InspectorPlusVar.LimitType.Max && !sp.hasMultipleDifferentValues)
        {
            sp.intValue = Mathf.Min(v.iMax, sp.intValue);
        }

        if (v.limitType == InspectorPlusVar.LimitType.Range)
        {
            if (!v.progressBar)
            {
                EditorGUI.BeginProperty(new Rect(0.0f, 0.0f, 0.0f, 0.0f), new GUIContent(), sp);
                EditorGUI.BeginChangeCheck();

                var newValue = EditorGUI.IntSlider(GUILayoutUtility.GetRect(18.0f, 18.0f), new GUIContent(dispName), sp.intValue, v.iMin, v.iMax);

                if (EditorGUI.EndChangeCheck())
                {
                    sp.intValue = newValue;
                }
                EditorGUI.EndProperty();
            }
            else
            {
                if (!sp.hasMultipleDifferentValues)
                {
                    sp.intValue = Mathf.Clamp(sp.intValue, v.iMin, v.iMax);
                    ProgressBar((float)(sp.intValue - v.iMin) / v.iMax, dispName);
                }
                else
                {
                    ProgressBar((float)(sp.intValue - v.iMin) / v.iMax, dispName);
                }
            }
        }
        else
        {
            EditorGUILayout.PropertyField(sp, new GUIContent(dispName));
        }
    }
Пример #3
0
    public override void OnInspectorGUI()
    {
        so.Update();
        RefreshVars();

        EditorGUIUtility.LookLikeControls(135.0f, 50.0f);

        for (int i = 0; i < properties.Length; i += 1)
        {
            InspectorPlusVar v = vars[i];

            if (v.active && properties[i] != null)
            {
                SerializedProperty sp = properties [i]; string s = v.type;
                bool skip = false;
                name     = v.name;
                dispName = v.dispName;

                GUI.enabled = v.canWrite;

                GUILayout.BeginHorizontal();

                if (v.toggleLevel != 0)
                {
                    GUILayout.Space(v.toggleLevel * 10.0f);
                }

                if (s == typeof(Vector2).Name)
                {
                    Vector2Field(sp);
                    skip = true;
                }
                if (s == typeof(int).Name)
                {
                    IntField(sp, v);
                    skip = true;
                }
                if (s == typeof(bool).Name)
                {
                    i   += BoolField(sp, v);
                    skip = true;
                }
                if (!skip)
                {
                    PropertyField(sp, name);
                }
                GUILayout.EndHorizontal();
                GUI.enabled = true;
            }
        }
        so.ApplyModifiedProperties();
        //NOTE NOTE NOTE: WATERMARK HERE
        //You are free to remove this
        //START REMOVE HERE
        GUILayout.BeginHorizontal();
        GUI.color = new Color(1.0f, 1.0f, 1.0f, 0.3f);
        GUILayout.FlexibleSpace();
        GUILayout.Label("Created with");
        GUI.color = new Color(1.0f, 1.0f, 1.0f, 0.6f);
        if (GUILayout.Button("Inspector++"))
        {
            Application.OpenURL("http://forum.unity3d.com/threads/136727-Inspector-Meh-to-WOW-inspectors");
        }
        GUI.color = new Color(1.0f, 1.0f, 1.0f);
        GUILayout.EndHorizontal();
        //END REMOVE HERE
    }