public float GetHeight(SerializedProperty property, GUIContent label, bool includeChildren) { float height = 0f; if (DecoratorDrawers != null && !IsCurrentlyNested) { foreach (var drawer in DecoratorDrawers) { height += drawer.GetHeight(); } } if (PropertyDrawer != null) { height += PropertyDrawer.GetPropertyHeightSafe(property.Copy(), label ?? EditorGUIUtilityHelper.TempContent(property.displayName)); } else if (!includeChildren) { height += EasyGUI.GetSinglePropertyHeight(property, label); } else { property = property.Copy(); // First property with custom label height += EasyGUI.GetSinglePropertyHeight(property, label); bool childrenAreExpanded = property.isExpanded && EasyGUI.HasVisibleChildFields(property); // Loop through all child properties var tc = EditorGUIUtilityHelper.TempContent(property.displayName); if (childrenAreExpanded) { SerializedProperty endProperty = property.GetEndProperty(); while (property.NextVisible(childrenAreExpanded) && !SerializedProperty.EqualContents(property, endProperty)) { height += ScriptAttributeUtility.GetHandler(property, null).GetHeight(property, tc, true); childrenAreExpanded = false; height += EasyGUI.kControlVerticalSpacing; } } } return(height); }
/// <summary> /// Handle the height calculation for the current property /// </summary> public float GetHeight(SerializedProperty inputProperty, GUIContent label, bool includeChildren) { float heightSoFar = 0f; // Handle decorator drawer heights if (decoratorDrawers != null && !IsCurrentlyNested) { // add up the heigh of all attached decorators foreach (DecoratorDrawer decoratorDrawer in decoratorDrawers) { heightSoFar += decoratorDrawer.GetHeight(); } } // Copy the property to ensure we don't break caller's position SerializedProperty property = inputProperty.Copy(); // If this is drawn by a Property drawer, use its height if (PropertyDrawer != null) { GUIContent curLabel = label ?? StratusEditorUtility.TempContent(property.displayName); return(PropertyDrawer.GetPropertyHeightSafe(property, curLabel) + heightSoFar); } // If this is an array header, special case it //if (Redacted.PaginatedArrayUtilities.IsArraySizeProperty(property)) //{ // return Redacted.PaginatedArrayUtilities.GetArrayHeaderSize(property) + heightSoFar; //} // Start with the default drawer heightSoFar += StratusEditorUtility.GetSinglePropertyHeight(property, label); // Has children that need to be drawn if (includeChildren && property.isExpanded) { SerializedProperty begin = null; SerializedProperty end = null; // Special case for paginated arrays if (property.isArray) { SerializedProperty sizeProperty = property.Copy(); sizeProperty.NextVisible(true); //heightSoFar += StratusEditorUtility.GetSinglePropertyHeight(sizeProperty, ) //heightSoFar += Redacted.PaginatedArrayUtilities.GetArrayHeaderSize(sizeProperty); //Redacted.PaginatedArrayUtilities.GetPagePropertyRange(property, ref begin, ref end); } else { begin = property.Copy(); begin.NextVisible(true); end = property.GetEndProperty(); } if (begin != null && end != null) { heightSoFar += GetHeightNestedRange(begin, end); } } return(heightSoFar); }