private static T DoEditSlow <T>(IPropertyEditorEditAPI api, Rect region, GUIContent label, T element, fiGraphMetadata metadata) { var dropdown = GetDropdownMetadata((IPropertyEditor)api, metadata); // Activate the foldout if we're above the minimum foldout height if (dropdown.ShouldDisplayDropdownArrow == false) { dropdown.ShouldDisplayDropdownArrow = region.height > fiSettings.MinimumFoldoutHeight; } // We're rendering dropdown logic if (dropdown.ShouldDisplayDropdownArrow) { // The foldout is hidden. Just draw the collapsed arrow and return. if (dropdown.IsActive == false) { // Some editors don't always supply a label (for example, the collection editors), // so instead of showing nothing we'll show the current ToString() value if (string.IsNullOrEmpty(label.text)) { label = new GUIContent(element != null ? element.ToString() : "Collapsed value"); } label = api.GetFoldoutHeader(label, element); region.width = EditorStyles.foldout.CalcSize(label).x; region.height = FoldoutHeight; // note: we don't use dropdown.IsActive = ... because we can be animating, and doing // that direct-assign toggle will cause the animation to flip-flop infinitely if (EditorGUI.Foldout(region, false, label, /*toggleOnLabelClick:*/ true) == true) { dropdown.IsActive = true; } return(element); } // Okay, we're going to be rendering the content of the body. We want to figure out how to // actually render the dropdown arrow. We do it in one of two ways: // 1. Draw using EditorGUI.Foldout with the full label // 2. Draw just the foldout and indent the rect if we're not in hierarchy mode // We have a couple of special cases to handle: // 1. We don't have a label // 2. The editor has non-standard label rendering // In these scenarioes, we will just draw the foldout arrow by itself and indent the contents of // the region. if (string.IsNullOrEmpty(label.text) || api.DisplaysStandardLabel == false) { Rect foldoutRegion = region; foldoutRegion.width = FoldoutEmptyWidth; foldoutRegion.height = FoldoutHeight; // note: We don't use dropdown.IsActive = ... because we can be animating, and doing // that direct-assign toggle will cause the animation to flip-flop infinitely if (EditorGUI.Foldout(foldoutRegion, true, GUIContent.none, /*toggleOnLabelClick:*/ true) == false) { dropdown.IsActive = false; } // Indent the body if we're not in hierarchy mode if (EditorGUIUtility.hierarchyMode == false) { region.x += foldoutRegion.width; region.width -= foldoutRegion.width; } } // We will render the foldout including the label else { Rect foldoutRegion = region; foldoutRegion.width = EditorStyles.foldout.CalcSize(label).x; foldoutRegion.height = FoldoutHeight; // note: We don't use dropdown.IsActive = ... because we can be animating, and doing // that direct-assign toggle will cause the animation to flip-flop infinitely if (EditorGUI.Foldout(foldoutRegion, true, label, /*toggleOnLabelClick:*/ true) == false) { dropdown.IsActive = false; } label = new GUIContent(" "); } } // Draw the actual edited content if (dropdown.IsAnimating) { fiEditorGUI.BeginFadeGroup(FoldoutHeight, ref region, dropdown.AnimPercentage); } var result = (T)api.Edit(region, label, element, metadata); if (dropdown.IsAnimating) { fiEditorGUI.EndFadeGroup(); } // End the cull zone. This should have been started inside of GetElementHeight, but if // for some reason GetElementHeight was never called, this will be harmless if not // currently in a cull-zone. metadata.EndCullZone(); return(result); }
private static T DoEditFast <T>(IPropertyEditorEditAPI api, Rect region, GUIContent label, T element, fiGraphMetadata metadata) { return((T)api.Edit(region, label, element, metadata)); }