public FieldInfoDrawer[] GenerateDrawers(FieldInfo[] fields) { int validTypes = 0; FieldInfoDrawer[] drawers = new FieldInfoDrawer[fields.Length]; for (int i = 0; i < fields.Length; ++i) { drawers[i] = new FieldInfoDrawer(fields[i]); if (drawers[i].isValid) { validTypes++; } } if (validTypes > 0) { isDrawable = true; } return(drawers); }
public bool DrawEditorGUILayout(FieldInfoDrawer drawer) { EditorGUI.BeginChangeCheck(); switch (drawer.propertyType) { case SerializedPropertyType.ObjectReference: drawer.field.SetValue(target, EditorGUILayout.ObjectField(drawer.label, drawer.GetValue <UnityEngine.Object>(target), drawer.type, true)); break; case SerializedPropertyType.Integer: drawer.field.SetValue(target, EditorGUILayout.IntField(drawer.label, drawer.GetValue <int>(target))); break; case SerializedPropertyType.Boolean: drawer.field.SetValue(target, EditorGUILayout.Toggle(drawer.label, drawer.GetValue <bool>(target))); break; case SerializedPropertyType.Float: drawer.field.SetValue(target, EditorGUILayout.FloatField(drawer.label, drawer.GetValue <float>(target))); break; case SerializedPropertyType.String: drawer.field.SetValue(target, EditorGUILayout.TextField(drawer.label, drawer.GetValue <string>(target))); break; case SerializedPropertyType.Color: drawer.field.SetValue(target, EditorGUILayout.ColorField(drawer.label, drawer.GetValue <Color>(target))); break; case SerializedPropertyType.LayerMask: drawer.field.SetValue(target, EditorGUILayout.LayerField(drawer.label, drawer.GetValue <LayerMask>(target))); break; case SerializedPropertyType.Enum: drawer.field.SetValue(target, EditorGUILayout.EnumPopup(drawer.label, drawer.GetValue <Enum>(target))); break; case SerializedPropertyType.Vector2: drawer.field.SetValue(target, EditorGUILayout.Vector2Field(drawer.label, drawer.GetValue <Vector2>(target))); break; case SerializedPropertyType.Vector3: drawer.field.SetValue(target, EditorGUILayout.Vector3Field(drawer.label, drawer.GetValue <Vector3>(target))); break; case SerializedPropertyType.Vector4: drawer.field.SetValue(target, EditorGUILayout.Vector4Field(drawer.label, drawer.GetValue <Vector4>(target))); break; case SerializedPropertyType.Rect: drawer.field.SetValue(target, EditorGUILayout.RectField(drawer.label, drawer.GetValue <Rect>(target))); break; default: break; } if (EditorGUI.EndChangeCheck()) { return(true); } return(false); }