Exemplo n.º 1
0
    void FloatField(SerializedProperty sp, InspectorPlusVar v)
    {
        if (v.limitType == InspectorPlusVar.LimitType.Min && !sp.hasMultipleDifferentValues)
        {
            sp.floatValue = Mathf.Max(v.min, sp.floatValue);
        }
        else if (v.limitType == InspectorPlusVar.LimitType.Max && !sp.hasMultipleDifferentValues)
        {
            sp.floatValue = Mathf.Min(v.max, sp.floatValue);
        }

        if (v.limitType == InspectorPlusVar.LimitType.Range)
        {
            if (!v.progressBar)
            {
                EditorGUILayout.Slider(sp, v.min, v.max);
            }
            else
            {
                if (!sp.hasMultipleDifferentValues)
                {
                    sp.floatValue = Mathf.Clamp(sp.floatValue, v.min, v.max);
                    ProgressBar((sp.floatValue - v.min) / v.max, dispName);
                }
                else
                {
                    ProgressBar((sp.floatValue - v.min) / v.max, dispName);
                }
            }
        }
        else
        {
            EditorGUILayout.PropertyField(sp, new GUIContent(dispName));
        }
    }
Exemplo n.º 2
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(float).Name)
                {
                    FloatField(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
    }