public static T DrawPropertyEditor <T>(T obj, fiGraphMetadata metadata) { var label = GUIContent.none; IPropertyEditor editor = PropertyEditor.Get(typeof(T), null).FirstEditor; var height = editor.GetElementHeight(label, obj, metadata.Enter("Root", metadata.Context)); Rect rect = new Rect(0, 0, 500, height); var serializedObj = obj as ISerializationCallbackReceiver; if (serializedObj != null) { serializedObj.OnBeforeSerialize(); serializedObj.OnAfterDeserialize(); } obj = editor.Edit(rect, label, obj, metadata.Enter("Root", metadata.Context)); if (serializedObj != null) { serializedObj.OnBeforeSerialize(); } return(obj); }
/// <summary> /// This method makes it easy to use a typical property editor as a GUILayout style method, /// where the rect is taken care of. /// </summary> /// <param name="editor">The editor that is being used.</param> /// <param name="label">The label to edit the region with.</param> /// <param name="element">The element that is being edited.</param> public static T EditWithGUILayout <T>(this IPropertyEditor editor, GUIContent label, T element, fiGraphMetadataChild metadata) { float height = editor.GetElementHeight(label, element, metadata); Rect region = EditorGUILayout.GetControlRect(false, height); if (Event.current.type != EventType.Layout) { return(editor.Edit(region, label, element, metadata)); } return(element); }
public float GetElementHeight(GUIContent label, object element, fiGraphMetadata metadata) { float height = EditorStyles.label.CalcHeight(label, 100); if (element != null) { PropertyEditorChain chain = PropertyEditor.Get(element.GetType(), null); IPropertyEditor editor = chain.SkipUntilNot(typeof(NullablePropertyEditor)); height += fiRectUtility.IndentVertical; height += editor.GetElementHeight(GUIContent.none, element, metadata.Enter("NullableEditor", metadata.Context)); } return(height); }
public float GetElementHeight(GUIContent label, object element, fiGraphMetadata metadata) { float height = EditorStyles.popup.CalcHeight(label, 100); height += fiRectUtility.IndentVertical; if (element != null) { PropertyEditorChain chain = PropertyEditor.Get(element.GetType(), null); IPropertyEditor editor = chain.SkipUntilNot(typeof(AbstractTypePropertyEditor)); height += editor.GetElementHeight(GUIContent.none, element, metadata.Enter("AbstractTypeEditor")); } var abstractTypeMetadata = metadata.GetMetadata <AbstractTypeAnimationMetadata>(); height = fiEditorGUI.AnimatedHeight(height, abstractTypeMetadata.ChangedTypes, metadata); abstractTypeMetadata.ChangedTypes = false; return(height); }
protected override float OnGetHeight(UnityObject behavior, fiGraphMetadata metadata) { fiGraphMetadataChild childMetadata = metadata.Enter("DefaultBehaviorEditor"); childMetadata.Metadata.GetPersistentMetadata <fiDropdownMetadata>().ForceDisable(); float height = 0; // We don't want to get the IObjectPropertyEditor for the given target, which extends // UnityObject, so that we can actually edit the property instead of getting a Unity // reference field. We also don't want the AbstractTypePropertyEditor, which we will get // if the behavior has any derived types. PropertyEditorChain editorChain = PropertyEditor.Get(behavior.GetType(), null); IPropertyEditor editor = editorChain.SkipUntilNot( typeof(IObjectPropertyEditor), typeof(AbstractTypePropertyEditor)); height += editor.GetElementHeight(GUIContent.none, behavior, childMetadata); return(height); }