protected override T Edit(Rect region, GUIContent label, T element, InspectorDisabledAttribute attribute, fiGraphMetadata metadata) { PropertyEditorChain chain = PropertyEditor.Get(typeof(T), null); EditorGUI.BeginDisabledGroup(true); element = chain.FirstEditor.Edit(region, label, element, metadata.Enter("InspectorDisabledAttribute")); EditorGUI.EndDisabledGroup(); return(element); }
public object Edit(Rect region, GUIContent label, object element, fiGraphMetadata metadata) { metadata.Enter("AbstractTypeEditor").Metadata.GetPersistentMetadata <fiDropdownMetadata>().ForceDisable(); try { fiEditorGUI.AnimatedBegin(ref region, metadata); _options.RemoveExtraneousOptions(); // draw the popup { int popupHeight = (int)EditorStyles.popup.CalcHeight(GUIContent.none, 100); Rect popupRegion = new Rect(region); popupRegion.height = popupHeight; region.y += popupRegion.height; region.height -= popupRegion.height; int selectedIndex = _options.GetDisplayOptionIndex(element); int updatedIndex = EditorGUI.Popup(popupRegion, label, selectedIndex, _options.GetDisplayOptions()); if (selectedIndex != updatedIndex) { metadata.GetMetadata <AbstractTypeAnimationMetadata>().ChangedTypes = true; } element = _options.UpdateObjectInstance(element, selectedIndex, updatedIndex); } // no element; no editor if (element == null) { return(null); } // draw the instance specific property editor { Rect selectedRegion = new Rect(region); selectedRegion = fiRectUtility.IndentedRect(selectedRegion); region.y += selectedRegion.height; region.height -= selectedRegion.height; // show custom editor PropertyEditorChain chain = PropertyEditor.Get(element.GetType(), null); IPropertyEditor editor = chain.SkipUntilNot(typeof(AbstractTypePropertyEditor)); return(editor.Edit(selectedRegion, GUIContent.none, element, metadata.Enter("AbstractTypeEditor"))); } } finally { fiEditorGUI.AnimatedEnd(metadata); } }
public object OnSceneGUI(object element) { if (element != null) { PropertyEditorChain chain = PropertyEditor.Get(element.GetType(), null); IPropertyEditor editor = chain.SkipUntilNot(typeof(AbstractTypePropertyEditor)); return(editor.OnSceneGUI(element)); } return(element); }
protected override T Edit(Rect region, GUIContent label, T element, InspectorDisabledIfAttribute attribute, fiGraphMetadata metadata) { PropertyEditorChain chain = PropertyEditor.Get(typeof(T), null); bool disabled = fiReflectionUtility.GetBooleanReflectedMember(typeof(T), element, attribute.ConditionalMemberName, true); EditorGUI.BeginDisabledGroup(disabled); element = chain.FirstEditor.Edit(region, label, element, metadata.Enter("InspectorDisabledIfAttribute")); EditorGUI.EndDisabledGroup(); return(element); }
protected override T Edit(Rect region, GUIContent label, T element, InspectorDisabledIfAttribute attribute, fiGraphMetadata metadata) { bool disabled = fiLogicalOperatorSupport.ComputeValue( attribute.Operator, attribute.ConditionalMemberNames, metadata.Context); EditorGUI.BeginDisabledGroup(disabled); PropertyEditorChain chain = PropertyEditor.Get(typeof(T), null); element = chain.FirstEditor.Edit(region, label, element, metadata.NoOp()); EditorGUI.EndDisabledGroup(); 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 object Edit(Rect region, GUIContent label, object element, fiGraphMetadata metadata) { // draw the nullable type toggle { int labelHeight = (int)EditorStyles.label.CalcHeight(GUIContent.none, 100); Rect toggleRegion = new Rect(region); toggleRegion.height = labelHeight; region.y += toggleRegion.height; region.height -= toggleRegion.height; if (EditorGUI.Toggle(toggleRegion, label, element != null)) { if (element == null) { element = _elementType.CreateInstance(); GUI.changed = true; } } else { element = null; } } // no element; no editor if (element == null) { return(null); } // we have a value for the nullable type; draw the property editor { Rect selectedRegion = new Rect(region); selectedRegion = fiRectUtility.IndentedRect(selectedRegion); region.y += selectedRegion.height; region.height -= selectedRegion.height; // show custom editor PropertyEditorChain chain = PropertyEditor.Get(element.GetType(), null); IPropertyEditor editor = chain.SkipUntilNot(typeof(NullablePropertyEditor)); return(editor.Edit(selectedRegion, GUIContent.none, element, metadata.Enter("NullableEditor", metadata.Context))); } }
public static void DisplayDeserializedObject(fiDeserializedObject obj, fiGraphMetadata metadata) { EditorGUILayout.BeginHorizontal(); GUILayout.Space(10); GUILayout.BeginVertical(); for (int i = 0; i < obj.Members.Count; ++i) { fiDeserializedMember member = obj.Members[i]; PropertyEditorChain editor = PropertyEditor.Get( member.InspectedProperty.StorageType, member.InspectedProperty.MemberInfo); GUILayout.BeginHorizontal(); member.ShouldRestore.Enabled = GUILayout.Toggle(member.ShouldRestore.Enabled, GUIContent.none, GUILayout.Width(15)); GUI.enabled = false; string label = member.InspectedProperty.DisplayName; if (member.ShouldRestore.Enabled) { editor.FirstEditor.EditWithGUILayout(new GUIContent(label), member.Value, metadata.Enter(label)); } else { GUILayout.Label(new GUIContent(label + " (will not restore)")); } GUI.enabled = true; GUILayout.EndHorizontal(); if (i != obj.Members.Count - 1) { fiEditorGUILayout.Splitter(1); } } GUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); }
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 GetElementHeight(GUIContent label, T element, InspectorDisabledAttribute attribute, fiGraphMetadata metadata) { PropertyEditorChain chain = PropertyEditor.Get(typeof(T), null); return(chain.FirstEditor.GetElementHeight(label, element, metadata.Enter("InspectorDisabledAttribute"))); }
public BaseCollectionPropertyEditor(Type editedType, ICustomAttributeProvider attributes) { ICustomAttributeProvider itemAttrs = null; { if (attributes != null) { var attrs = attributes.GetCustomAttributes(typeof(InspectorCollectionItemAttributesAttribute), true); if (attrs != null && attrs.Length == 1) { itemAttrs = ((InspectorCollectionItemAttributesAttribute)attrs[0]).AttributeProvider; } } } _itemEditor = PropertyEditor.Get(typeof(TItem), itemAttrs); ICustomAttributeProvider addItemAttrs = null; { if (attributes != null) { var attrs = attributes.GetCustomAttributes(typeof(InspectorCollectionAddItemAttributesAttribute), true); if (attrs != null && attrs.Length == 1) { addItemAttrs = ((InspectorCollectionAddItemAttributesAttribute)attrs[0]).AttributeProvider; } } } _addItemEditor = PropertyEditor.Get(typeof(TAddItem), addItemAttrs); _itemDefaultFoldoutState = CollectionItemDefaultFoldoutState.DisableFoldouts; if (attributes != null && attributes.IsDefined(typeof(InspectorCollectionShowItemDropdownAttribute), true)) { var attr = (InspectorCollectionShowItemDropdownAttribute) (attributes.GetCustomAttributes(typeof(InspectorCollectionShowItemDropdownAttribute), true)[0]); _itemDefaultFoldoutState = attr.IsCollapsedByDefault ? CollectionItemDefaultFoldoutState.Collapsed : CollectionItemDefaultFoldoutState.Expanded; } if (DisplayAddItemPreview) { _listFlags |= ReorderableListFlags.HideAddButton; } if (!AllowReordering) { _listFlags |= ReorderableListFlags.DisableReordering; } if (attributes != null && attributes.IsDefined(typeof(InspectorCollectionRotorzFlagsAttribute), /*inherit:*/ true)) { var attr = (InspectorCollectionRotorzFlagsAttribute)(attributes.GetCustomAttributes(typeof(InspectorCollectionRotorzFlagsAttribute), /*inherit:*/ true)[0]); _listFlags |= attr.Flags; } _pageMinimumCollectionLength = fiSettings.DefaultPageMinimumCollectionLength; if (attributes != null && attributes.IsDefined(typeof(InspectorCollectionPagerAttribute), /*inherit:*/ true)) { var attr = (InspectorCollectionPagerAttribute)(attributes.GetCustomAttributes(typeof(InspectorCollectionPagerAttribute), /*inherit:*/ true)[0]); _pageMinimumCollectionLength = attr.PageMinimumCollectionLength; } }