Пример #1
0
 private void DrawInt(string title, int i1, ref int i2)
 {
     if (i1 != i2)
     {
         MarkError();
         EditorGUILayoutEx.IntField(title, ref i2);
         ClearError();
     }
     else
     {
         EditorGUILayoutEx.IntField(title, ref i2, EditorStyles.toolbarTextField);
     }
 }
Пример #2
0
        public override void OnFooterGUI()
        {
            EditorGUILayout.BeginHorizontal();
            Type fieldType = null;

            if (field != null)
            {
                fieldType = field.FieldType;
            }
            else if (property != null)
            {
                fieldType = property.PropertyType;
            }

            if (fieldType != null)
            {
                if (fieldType == typeof(int))
                {
                    EditorGUILayoutEx.IntField("Value", ref intVal);
                    val = intVal;
                }
                else if (fieldType == typeof(bool))
                {
                    EditorGUILayoutEx.Toggle("Value", ref boolVal);
                    val = boolVal;
                }
                else if (fieldType == typeof(Vector2))
                {
                    EditorGUILayoutEx.Vector2Field("Value", ref vec2Val);
                    val = vec2Val;
                }
                else if (fieldType == typeof(Vector3))
                {
                    EditorGUILayoutEx.Vector3Field("Value", ref vec3Val);
                    val = vec3Val;
                }
                else if (fieldType == typeof(Vector4))
                {
                    EditorGUILayoutEx.Vector4Field("Value", ref vec4Val);
                    val = vec4Val;
                }
                else if (fieldType == typeof(Color))
                {
                    EditorGUILayoutEx.ColorField("Value", ref colorVal);
                    val = colorVal;
                }
                else if (fieldType == typeof(string))
                {
                    EditorGUILayoutEx.TextField("Value", ref strVal);
                    val = strVal;
                }
                else if (fieldType.IsEnum)
                {
                    EditorGUILayoutEx.PopupEnum(fieldType, "Value", ref enumVal);
                    val = enumVal;
                }
                else
                {
                    EditorGUILayoutEx.ObjectField <Object>("Value", ref objVal, true);
                    val = objVal;
                    if (objVal != null)
                    {
                        if (objVal is GameObject && !fieldType.IsInstanceOfType(val))
                        {
                            Component c = (objVal as GameObject).GetComponent(fieldType);
                            if (c != null)
                            {
                                val = c;
                            }
                        }
                    }
                }
            }
            using (new EditorGUI.DisabledScope((applyOnSelection || root != null) && fieldType != null))
            {
                if (GUILayout.Button("Allocate"))
                {
                    Allocate();
                }
            }
            EditorGUILayout.EndHorizontal();
        }
Пример #3
0
 protected override void DrawInspectorImpl()
 {
     EditorGUILayoutEx.IntField("Compressed", ref compressed);
 }