public OnGUI ( |
||
position | Rectangle on the screen to use for the decorator GUI. | |
return | void |
public bool OnGUI(Rect position, SerializedProperty property, GUIContent label, bool includeChildren) { float height = position.height; position.height = 0.0f; if (this.m_DecoratorDrawers != null && !this.isCurrentlyNested) { using (List <DecoratorDrawer> .Enumerator enumerator = this.m_DecoratorDrawers.GetEnumerator()) { while (enumerator.MoveNext()) { DecoratorDrawer current = enumerator.Current; position.height = current.GetHeight(); float labelWidth = EditorGUIUtility.labelWidth; float fieldWidth = EditorGUIUtility.fieldWidth; current.OnGUI(position); EditorGUIUtility.labelWidth = labelWidth; EditorGUIUtility.fieldWidth = fieldWidth; position.y += position.height; height -= position.height; } } } position.height = height; if (this.propertyDrawer != null) { float labelWidth = EditorGUIUtility.labelWidth; float fieldWidth = EditorGUIUtility.fieldWidth; this.propertyDrawer.OnGUISafe(position, property.Copy(), label ?? EditorGUIUtility.TempContent(property.displayName)); EditorGUIUtility.labelWidth = labelWidth; EditorGUIUtility.fieldWidth = fieldWidth; return(false); } if (!includeChildren) { return(EditorGUI.DefaultPropertyField(position, property, label)); } Vector2 iconSize = EditorGUIUtility.GetIconSize(); bool enabled = GUI.enabled; int indentLevel = EditorGUI.indentLevel; int num = indentLevel - property.depth; SerializedProperty serializedProperty = property.Copy(); SerializedProperty endProperty = serializedProperty.GetEndProperty(); position.height = EditorGUI.GetSinglePropertyHeight(serializedProperty, label); EditorGUI.indentLevel = serializedProperty.depth + num; bool enterChildren = EditorGUI.DefaultPropertyField(position, serializedProperty, label) && EditorGUI.HasVisibleChildFields(serializedProperty); position.y += position.height + 2f; while (serializedProperty.NextVisible(enterChildren) && !SerializedProperty.EqualContents(serializedProperty, endProperty)) { EditorGUI.indentLevel = serializedProperty.depth + num; position.height = EditorGUI.GetPropertyHeight(serializedProperty, (GUIContent)null, false); EditorGUI.BeginChangeCheck(); enterChildren = ScriptAttributeUtility.GetHandler(serializedProperty).OnGUI(position, serializedProperty, (GUIContent)null, false) && EditorGUI.HasVisibleChildFields(serializedProperty); if (!EditorGUI.EndChangeCheck()) { position.y += position.height + 2f; } else { break; } } GUI.enabled = enabled; EditorGUIUtility.SetIconSize(iconSize); EditorGUI.indentLevel = indentLevel; return(false); }