Beispiel #1
0
            public override bool DrawEditorGUILayout(object target, bool isChild = false)
            {
                EditorGUI.BeginChangeCheck();
                switch (propertyType)
                {
                case SerializedPropertyType.ObjectReference:
                    this.field.SetValue(target, UnityEditor.EditorGUILayout.ObjectField(name, this.GetValue <UnityEngine.Object>(target), type, true));
                    break;

                case SerializedPropertyType.Integer:
                    this.field.SetValue(target, UnityEditor.EditorGUILayout.IntField(name, this.GetValue <int>(target)));
                    break;

                case SerializedPropertyType.Boolean:
                    this.field.SetValue(target, UnityEditor.EditorGUILayout.Toggle(name, this.GetValue <bool>(target)));
                    break;

                case SerializedPropertyType.Float:
                    OnFloatEditorGUILayout(target);
                    break;

                case SerializedPropertyType.String:
                    this.field.SetValue(target, UnityEditor.EditorGUILayout.TextField(name, this.GetValue <string>(target)));
                    break;

                case SerializedPropertyType.Color:
                    this.field.SetValue(target, UnityEditor.EditorGUILayout.ColorField(name, this.GetValue <Color>(target)));
                    break;

                case SerializedPropertyType.LayerMask:
                    this.field.SetValue(target, UnityEditor.EditorGUILayout.LayerField(name, this.GetValue <LayerMask>(target)));
                    break;

                case SerializedPropertyType.Enum:
                    this.field.SetValue(target, UnityEditor.EditorGUILayout.EnumPopup(name, this.GetValue <Enum>(target)));
                    break;

                case SerializedPropertyType.Vector2:
                    this.field.SetValue(target, UnityEditor.EditorGUILayout.Vector2Field(name, this.GetValue <Vector2>(target)));
                    break;

                case SerializedPropertyType.Vector3:
                    this.field.SetValue(target, UnityEditor.EditorGUILayout.Vector3Field(name, this.GetValue <Vector3>(target)));
                    break;

                case SerializedPropertyType.Vector4:
                    this.field.SetValue(target, UnityEditor.EditorGUILayout.Vector4Field(name, this.GetValue <Vector4>(target)));
                    break;

                case SerializedPropertyType.Rect:
                    this.field.SetValue(target, UnityEditor.EditorGUILayout.RectField(name, this.GetValue <Rect>(target)));
                    break;

                default:
                    if (isArray)
                    {
                        EditorGUILayout.Space();
                        StratusReorderableList.DrawCachedPolymorphicList(this.field, target);
                    }
                    else
                    {
                        UnityEditor.EditorGUILayout.LabelField($"No drawer implementation for {name} of type {type.Name}");
                    }
                    break;
                }

                if (EditorGUI.EndChangeCheck())
                {
                    return(true);
                }

                return(false);
            }