private static float GetItemHeight(UnityObject item, fiGraphMetadataChild metadata) { return(EditorStyles.label.CalcHeight(GUIContent.none, 100)); }
private static string DrawItem(Rect position, string item, fiGraphMetadataChild metadata) { return(EditorGUI.TextField(position, item)); }
private static UnityObject DrawItem(Rect position, UnityObject item, fiGraphMetadataChild metadata) { return(EditorGUI.ObjectField(position, item, typeof(UnityObject), /*allowSceneObjects:*/ true)); }
/// <summary> /// Display a Unity inspector GUI that provides an editing interface for the given object. /// </summary> /// <param name="region">The rect on the screen to draw the GUI controls.</param> /// <param name="label">The label to label the controls with.</param> /// <param name="element">The element itself to edit. This can be mutated directly. For /// values which cannot be mutated, such as structs, the return value is used to update the /// stored value.</param> /// <returns>An updated instance of the element.</returns> public static T Edit <T>(this IPropertyEditor editor, Rect region, GUIContent label, T element, fiGraphMetadataChild metadata) { var api = GetEditingAPI(editor); return(DoEdit(api, region, label, element, metadata.Metadata)); }
/// <summary> /// Returns the height of the region that needs editing. /// </summary> /// <param name="label">The label that will be used when editing.</param> /// <param name="element">The element that will be edited.</param> /// <returns>The height of the region that needs editing.</returns> public static float GetElementHeight <T>(this IPropertyEditor editor, GUIContent label, T element, fiGraphMetadataChild metadata) { bool hasCachedHeight; CachedHeightMedatadata cachedHeight = metadata.Metadata.GetMetadata <CachedHeightMedatadata>(out hasCachedHeight); hasCachedHeight = !hasCachedHeight; // If we're calling from an Edit method, just reuse the last height computation (if we have a previous height computation). if (hasCachedHeight && BaseMethod == BaseMethodCall.Edit) { return(cachedHeight.CachedHeight); } // If we're a dropdown that is not active, show the general foldout height var dropdown = metadata.Metadata.GetPersistentMetadata <fiDropdownMetadata>(); if (dropdown.ShouldDisplayDropdownArrow && dropdown.IsAnimating == false && dropdown.IsActive == false) { cachedHeight.CachedHeight = FoldoutHeight; return(FoldoutHeight); } bool setBaseMethod = false; if (hasCachedHeight) { BeginMethodSet(BaseMethodCall.GetElementHeight, out setBaseMethod); } try { // We begin (but do not end) the cull zone here. The cull zone is terminated inside // of Edit(). It is safe to call BeginCullZone() multiple times -- it has no // effect past the first call. metadata.Metadata.BeginCullZone(); var api = GetEditingAPI(editor); float height = api.GetElementHeight(label, element, metadata.Metadata); if (dropdown.IsAnimating) { fiEditorUtility.RepaintAllEditors(); fiEditorGUI.UpdateFadeGroupHeight(ref height, FoldoutHeight, dropdown.AnimPercentage); } return(metadata.Metadata.GetMetadata <CachedHeightMedatadata>().CachedHeight = height); } finally { if (hasCachedHeight) { EndMethodSet(setBaseMethod); } } }
/// <summary> /// Display a Unity inspector GUI that provides an editing interface for /// the given object. /// </summary> /// <param name="region"> /// The rect on the screen to draw the GUI controls. /// </param> /// <param name="label">The label to label the controls with.</param> /// <param name="element"> /// The element itself to edit. This can be mutated directly. For values /// which cannot be mutated, such as structs, the return value is used to /// update the stored value. /// </param> /// <returns>An updated instance of the element.</returns> public static T Edit <T>(this IPropertyEditor editor, Rect region, GUIContent label, T element, fiGraphMetadataChild metadata) { var api = GetEditingAPI(editor); bool setBaseMethod; BeginMethodSet(BaseMethodCall.Edit, out setBaseMethod); try { EditorGUIUtility.labelWidth = fiGUI.PushLabelWidth(label, region.width); // TODO: introduce a fast-path, we are burning lots of time in // this function T result; if (typeof(T).IsPrimitive) { result = DoEditFast(api, region, label, element, metadata.Metadata); } else { result = DoEditSlow(api, region, label, element, metadata.Metadata); } EditorGUIUtility.labelWidth = fiGUI.PopLabelWidth(); return(result); } finally { EndMethodSet(setBaseMethod); } }