public static object Draw(Rect position, GUIContent label, object o, int currentDepth) { position.height = EditorGUIUtility.singleLineHeight; if (o == null) { EditorGUI.LabelField(position, "Drawing null!"); return(o); } EditorGUI.LabelField(position, label); EditorGUI.indentLevel++; foreach (var field in FieldUtil.DrawableFields(o.GetType())) { var fieldValue = field.GetValue(o); var valueType = field.FieldType; position = EditorUtil.NextPosition(position, FieldUtil.HeightRequiredToDraw(field.FieldType)); var newValue = SerializableArgumentDrawer.DrawObjectOfType(position, new GUIContent(field.Name), valueType, fieldValue, currentDepth + 1); field.SetValue(o, newValue); } EditorGUI.indentLevel--; return(o); }
public static float GetHeightForType(Type type, float defaultHeight, int depth) { //nonstandard heights if (type == typeof(Bounds)) { return(defaultHeight * 3f); } if (type == typeof(Rect)) { return(defaultHeight * 2f); } if (type == typeof(Color)) { return(defaultHeight); } if (type == typeof(AnimationCurve)) { return(defaultHeight); } if (type.IsEnum) { return(defaultHeight); } if (type == typeof(float)) { return(defaultHeight); } if (type == typeof(int)) { return(defaultHeight); } if (type == typeof(string)) { return(defaultHeight); } if (type == typeof(bool)) { return(defaultHeight); } if (type == typeof(Vector2)) { return(defaultHeight); } if (type == typeof(Vector3)) { return(defaultHeight); } if (type == typeof(Vector4)) { return(defaultHeight); } if (type == typeof(Quaternion)) { return(defaultHeight); } if (typeof(Object).IsAssignableFrom(type)) { return(defaultHeight); } return(depth < SerializableSystemType.MaxSerializationDepth ? FieldUtil.HeightRequiredToDraw(type, depth + 1) : defaultHeight); }