protected virtual void EmitPropertyField(Rect position, UnityEditor.SerializedProperty targetSerializedProperty, GUIContent label) { MultilineReactivePropertyAttribute multiline = GetMultilineAttribute(); if (multiline == null) { RangeReactivePropertyAttribute range = GetRangeAttribute(); if (range == null) { UnityEditor.EditorGUI.PropertyField(position, targetSerializedProperty, label, includeChildren: true); } else { if (targetSerializedProperty.propertyType == SerializedPropertyType.Float) { EditorGUI.Slider(position, targetSerializedProperty, range.Min, range.Max, label); } else if (targetSerializedProperty.propertyType == SerializedPropertyType.Integer) { EditorGUI.IntSlider(position, targetSerializedProperty, (int)range.Min, (int)range.Max, label); } else { EditorGUI.LabelField(position, label.text, "Use Range with float or int."); } } } else { SerializedProperty property = targetSerializedProperty; label = EditorGUI.BeginProperty(position, label, property); MethodInfo method = typeof(EditorGUI).GetMethod("MultiFieldPrefixLabel", BindingFlags.Static | BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.NonPublic); position = (Rect)method.Invoke(null, new object[] { position, 0, label, 1 }); EditorGUI.BeginChangeCheck(); int indentLevel = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; string stringValue = EditorGUI.TextArea(position, property.stringValue); EditorGUI.indentLevel = indentLevel; if (EditorGUI.EndChangeCheck()) { property.stringValue = stringValue; } EditorGUI.EndProperty(); } }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { InspectorDisplayAttribute attr = this.attribute as InspectorDisplayAttribute; string fieldName = (attr == null) ? "value" : attr.FieldName; float height = base.GetPropertyHeight(property, label); SerializedProperty valueProperty = property.FindPropertyRelative(fieldName); if (valueProperty == null) { return(height); } if (valueProperty.propertyType == SerializedPropertyType.Rect) { return(height * 2); } if (valueProperty.propertyType == SerializedPropertyType.Bounds) { return(height * 3); } if (valueProperty.propertyType == SerializedPropertyType.String) { MultilineReactivePropertyAttribute multilineAttr = GetMultilineAttribute(); if (multilineAttr != null) { return(((!EditorGUIUtility.wideMode) ? 16f : 0f) + 16f + (float)((multilineAttr.Lines - 1) * 13)); } ; } if (valueProperty.isExpanded) { int count = 0; IEnumerator e = valueProperty.GetEnumerator(); while (e.MoveNext()) { count++; } return(((height + 4) * count) + 6); // (Line = 20 + Padding) ? } return(height); }