public override UnityObject Edit(Rect region, GUIContent label, UnityObject element, fiGraphMetadata metadata) { if (CanDisplayDropdown(element) == false) { region.height = FoldoutHeight; return(fiEditorGUI.ObjectField(region, label, element, typeof(ObjectType), AllowSceneObjects(element))); } // We have to show a foldout. DisableFoldoutByDefault(element, metadata); // The rect for the foldout Rect foldoutRect = region; foldoutRect.height = FoldoutHeight; if (string.IsNullOrEmpty(label.text) == false) { foldoutRect.width = EditorGUIUtility.labelWidth; } else { foldoutRect.width = 15; } Rect objectRect = region; objectRect.x += foldoutRect.width; objectRect.width -= foldoutRect.width; objectRect.height = FoldoutHeight; var foldoutState = metadata.GetMetadata <ObjectFoldoutStateGraphMetadata>(); bool updatedActive = EditorGUI.Foldout(foldoutRect, foldoutState.IsActive, label, /*toggleOnLabelClick:*/ true); if (updatedActive != foldoutState.IsActive && foldoutState.IsAnimating == false) { foldoutState.IsActive = updatedActive; } element = fiEditorGUI.ObjectField(objectRect, GUIContent.none, element, typeof(ObjectType), AllowSceneObjects(element)); if (element != null && (foldoutState.IsActive || foldoutState.IsAnimating)) { Rect subRect = new Rect(region); subRect.y += FoldoutHeight; subRect.height -= FoldoutHeight; fiEditorGUI.BeginFadeGroup(0, ref subRect, foldoutState.AnimPercentage); // Reuse the height calculation from GetHeight from the BehaviorEditor by // calculating the base height of the layout when the dynamic item does not // contribute. DynamicItemHeight.SetHeight(0); DynamicItemHeight.SetHeight(subRect.height - DisplayedItemLayout.Height); Rect boxRect = DisplayedItemLayout.GetSectionRect("Box", subRect); Rect propertyRect = DisplayedItemLayout.GetSectionRect("Item", subRect); GUI.Box(boxRect, GUIContent.none); fiEditorGUI.PushHierarchyMode(false); var editor = BehaviorEditor.Get(element.GetType()); editor.Edit(propertyRect, element); fiEditorGUI.PopHierarchyMode(); fiEditorGUI.EndFadeGroup(); if (foldoutState.IsAnimating) { fiEditorUtility.RepaintAllEditors(); } } return(element); }
protected override void OnEdit(Rect rect, Transform behavior, fiGraphMetadata metadata) { behavior.position = EditorGUI.Vector3Field(Layout.GetSectionRect("Position", rect), "Position", behavior.position); behavior.rotation = Quaternion.Euler(EditorGUI.Vector3Field(Layout.GetSectionRect("Rotation", rect), "Rotation", behavior.rotation.eulerAngles)); behavior.localScale = EditorGUI.Vector3Field(Layout.GetSectionRect("Scale", rect), "Scale", behavior.localScale); }