예제 #1
0
        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);
        }
예제 #2
0
 public void InheritedPropertyEditorTest()
 {
     Assert.IsInstanceOf <IListPropertyEditor <List <int>, int> >(PropertyEditor.Get(typeof(List <int>), null).FirstEditor);
     Assert.IsInstanceOf <IListPropertyEditor <CustomList, int> >(PropertyEditor.Get(typeof(CustomList), null).FirstEditor);
     Assert.IsInstanceOf <IListPropertyEditor <CustomList <int>, int> >(PropertyEditor.Get(typeof(CustomList <int>), null).FirstEditor);
     Assert.IsInstanceOf <IListPropertyEditor <CustomList <string>, string> >(PropertyEditor.Get(typeof(CustomList <string>), null).FirstEditor);
 }
예제 #3
0
        public void ComponentTest()
        {
            ObjectPropertyEditor <Transform> oo = new ObjectPropertyEditor <Transform>();

            Assert.IsTrue(oo.CanEdit(typeof(Transform)));

            Assert.IsInstanceOf <ObjectPropertyEditor <Transform> >(PropertyEditor.Get(typeof(Transform), null).FirstEditor);
        }
 private static IPropertyEditor GetEditor(object element)
 {
     if (element == null)
     {
         return(PropertyEditor.Get(typeof(T), null).FirstEditor);
     }
     return(PropertyEditor.Get(element.GetType(), null).SkipUntilNot(typeof(AbstractTypePropertyEditor)));
 }
예제 #5
0
 private static IPropertyEditor GetEditor(object element)
 {
     if (element == null)
     {
         return(PropertyEditor.Get(typeof(T), null).FirstEditor);
     }
     return(PropertyEditor.Get(element.GetType(), null).FirstEditor);
 }
        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);
            }
        }
예제 #8
0
        public override SharedInstance <T, TSerializer> Edit(Rect region, GUIContent label, SharedInstance <T, TSerializer> element, fiGraphMetadata metadata)
        {
            TryEnsureScript();

            if (typeof(TActual).IsGenericType)
            {
                region = EditorGUI.PrefixLabel(region, label);


                float ButtonRectWidth = 23;
                Rect  buttonRect = region, objectRect = region;

                buttonRect.x     += buttonRect.width - ButtonRectWidth;
                buttonRect.width  = ButtonRectWidth;
                buttonRect.height = EditorGUIUtility.singleLineHeight;

                objectRect.width -= buttonRect.width;

                if (GUI.Button(buttonRect, new GUIContent("\u2261")))
                {
                    fiSharedInstanceSelectorWindow.Show(typeof(T), typeof(SharedInstance <T, TSerializer>),
                                                        instance => {
                        metadata.GetMetadata <SharedInstanceMetadata>().UpdatedInstance = fiOption.Just((SharedInstance <T, TSerializer>)instance);
                    });
                }

                fiEditorGUI.PushHierarchyMode(false);
                // Use the standard object property editor
                element = EditorChain.GetNextEditor(this).Edit(objectRect, GUIContent.none, element, metadata.Enter("ObjectReference"));
                fiEditorGUI.PopHierarchyMode();
            }
            else
            {
                if (element != null)
                {
                    fiEditorGUI.PushHierarchyMode(false);
                    element.Instance = PropertyEditor.Get(typeof(T), null).FirstEditor.Edit(region, new GUIContent("Instance"), element.Instance, new fiGraphMetadataChild {
                        Metadata = metadata
                    });
                    fiEditorGUI.PopHierarchyMode();
                }
            }

            var sharedInstanceMetadata = metadata.GetMetadata <SharedInstanceMetadata>();

            if (sharedInstanceMetadata.UpdatedInstance.HasValue)
            {
                element = sharedInstanceMetadata.UpdatedInstance.Value;
                sharedInstanceMetadata.UpdatedInstance = fiOption <SharedInstance <T, TSerializer> > .Empty;
                GUI.changed = true;
            }

            return(element);
        }
        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);
        }
        public override float GetElementHeight(GUIContent label, SharedInstance <T, TSerializer> element, fiGraphMetadata metadata)
        {
            if (typeof(TActual).IsGenericType == false)
            {
                return(PropertyEditor.Get(typeof(T), null).FirstEditor.GetElementHeight(new GUIContent("Instance"), element.Instance, new fiGraphMetadataChild {
                    Metadata = metadata
                }));
            }

            TryEnsureScript();
            return(EditorChain.GetNextEditor(this).GetElementHeight(label, element, metadata.Enter("ObjectReference", metadata.Context)));
        }
예제 #11
0
        public static float EditPropertyHeightDirect(InspectedProperty property, object propertyValue, fiGraphMetadataChild metadataChild)
        {
            fiGraphMetadata metadata = metadataChild.Metadata;

            var editor = PropertyEditor.Get(property.StorageType, property.MemberInfo).FirstEditor;

            GUIContent propertyLabel = new GUIContent(property.DisplayName);

            // Either the foldout is active or we are not displaying a foldout.
            // Either way, we want to report the full height of the property.
            return(editor.GetElementHeight(propertyLabel, propertyValue, metadata.Enter("EditProperty", metadata.Context)));
        }
        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);
        }
        public void OnGUI()
        {
            PropertyEditor.Get(_resources.GetType(), null)
            .FirstEditor
            .EditWithGUILayout(new GUIContent("Resources"), _resources, _metadata.Enter("Resources", null));

            if (GUILayout.Button("Write To Disk"))
            {
                const string outputPath = "Assets/FullInspector2/Modules/EditorImagesManager/Editor/fiEditorImages.cs";
                File.WriteAllText(outputPath, BuildFile(_resources));
                AssetDatabase.Refresh();
            }
        }
        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);
        }
예제 #15
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            if (IsEnabled)
            {
                var propertyType = fieldInfo.FieldType;
                var target       = fiSerializedPropertyUtility.GetTarget(property);
                var metadata     = fiSerializedPropertyUtility.GetMetadata(property);
                var editor       = PropertyEditor.Get(propertyType, fieldInfo).FirstEditor;

                return(editor.GetElementHeight(label, target, metadata));
            }

            return(EditorGUI.GetPropertyHeight(property, label));
        }
예제 #16
0
        public object OnSceneGUI(object element)
        {
            try {
                if (_cycleScene == null)
                {
                    _cycleScene = new fiCycleDetector(_cycleEdit, _cycleHeight);
                }
                _cycleScene.Enter();

                // cycle; don't do anything
                if (_cycleScene.TryMark(element) == false)
                {
                    return(element);
                }

                // Not showing a scene GUI for the object for this frame should be fine
                if (element == null)
                {
                    return(element);
                }

                var inspectedProperties = _metadata.GetProperties(InspectedMemberFilters.InspectableMembers);
                for (int i = 0; i < inspectedProperties.Count; ++i)
                {
                    var property = inspectedProperties[i];

                    var             editorChain = PropertyEditor.Get(property.StorageType, property.MemberInfo);
                    IPropertyEditor editor      = editorChain.FirstEditor;

                    object currentValue = property.Read(element);
                    object updatedValue = editor.OnSceneGUI(currentValue);

                    // We use EqualityComparer instead of == because EqualityComparer will properly unbox structs
                    if (EqualityComparer <object> .Default.Equals(currentValue, updatedValue) == false)
                    {
                        property.Write(element, updatedValue);
                    }
                }

                return(element);
            }
            finally {
                _cycleScene.Exit();
                if (_cycleScene.Depth == 0)
                {
                    _cycleScene = null;
                }
            }
        }
예제 #17
0
        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);
        }
예제 #18
0
    public override void OnInspectorGUI()
    {
        TextAsset asset = (TextAsset)target;

        if (IsJsonAsset(asset))
        {
            fsData data = fsJsonParser.Parse(asset.text);
            PropertyEditor.Get(typeof(fsData), null)
            .FirstEditor.EditWithGUILayout(GUIContent.none, data, new fiGraphMetadataChild {
                Metadata = fiPersistentMetadata.GetMetadataFor(target)
            });

            return;
        }

        DrawDefaultInspector();
    }
예제 #19
0
        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);
        }
        public override void OnInspectorGUI()
        {
            TextAsset asset = (TextAsset)target;

            if (IsJsonAsset(asset))
            {
                fsData   data;
                fsResult result = fsJsonParser.Parse(asset.text, out data);
                if (result.Succeeded)
                {
                    PropertyEditor.Get(typeof(fsData), null)
                    .FirstEditor.EditWithGUILayout(GUIContent.none, data, new fiGraphMetadataChild {
                        Metadata = fiPersistentMetadata.GetMetadataFor(target)
                    });

                    return;
                }
            }

            base.OnInspectorGUI();
        }
예제 #23
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (IsEnabled)
            {
                var propertyType = fieldInfo.FieldType;
                var target       = fiSerializedPropertyUtility.GetTarget(property);
                var metadata     = fiSerializedPropertyUtility.GetMetadata(property);
                var editor       = PropertyEditor.Get(propertyType, fieldInfo).FirstEditor;

                if (property.prefabOverride)
                {
                    fiUnityInternalReflection.SetBoldDefaultFont(true);
                }

                var savedHierarchyMode = EditorGUIUtility.hierarchyMode;
                EditorGUIUtility.hierarchyMode = true;

                EditorGUI.BeginChangeCheck();
                target = editor.Edit(position, label, target, metadata);

                if (EditorGUI.EndChangeCheck())
                {
                    fiSerializedPropertyUtility.WriteTarget(property, target);
                    EditorUtility.SetDirty(property.serializedObject.targetObject);
                }

                EditorGUIUtility.hierarchyMode = savedHierarchyMode;

                if (property.prefabOverride)
                {
                    fiUnityInternalReflection.SetBoldDefaultFont(false);
                }

                fiSerializedPropertyUtility.RevertPrefabContextMenu(position, property);
                return;
            }

            EditorGUI.PropertyField(position, property, label);
        }
예제 #24
0
        /// <summary>
        /// Draws a GUI for editing the given property and returns the updated
        /// value. This does
        /// *not* write the updated value to a container.
        /// </summary>
        /// <param name="context">
        /// An optional context that the property value came from. If this is not
        /// given, then a prefab context menu will not be displayable.
        /// </param>
        public static object EditPropertyDirect(Rect region, InspectedProperty property, object propertyValue, fiGraphMetadataChild metadataChild, object context)
        {
            fiGraphMetadata metadata = metadataChild.Metadata;

            // Show a "revert to prefab" value context-menu if possible
            if (context != null)
            {
                RevertPrefabContextMenu(region, context, property);
            }

            // get the label / tooltip
            GUIContent label = new GUIContent(property.DisplayName,
                                              InspectorTooltipAttribute.GetTooltip(property.MemberInfo));

            var             editorChain = PropertyEditor.Get(property.StorageType, property.MemberInfo);
            IPropertyEditor editor      = editorChain.FirstEditor;

            EditorGUI.BeginDisabledGroup(property.CanWrite == false);
            propertyValue = editor.Edit(region, label, propertyValue, metadata.Enter("EditProperty", metadata.Context));
            EditorGUI.EndDisabledGroup();

            return(propertyValue);
        }
예제 #25
0
        public void OnGUI()
        {
            EnsureResources();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            _disablePopups = GUILayout.Toggle(_disablePopups, "Disable Dialog Boxes");
            GUILayout.EndHorizontal();

            GUILayout.Label("<b><size=25>About</size></b> If you've decided to change serializers (for example, from Json.NET to Full Serializer), then this utility will assist your migration.", RichLabel);

            fiEditorGUILayout.Splitter(3);

            IPropertyEditor editor = PropertyEditor.Get(typeof(TypeSpecifier <BaseSerializer>), null).FirstEditor;

            GUILayout.Label("Select the <i>current</i> serializer and then the <i>new</i> serializer", RichLabel);

            fiEditorGUILayout.WithIndent(50, () => {
                WithTemporaryLabelWidth(120, () => {
                    editor.EditWithGUILayout(new GUIContent("Current Serializer"), _currentSerializer, _metadata.Enter(0));
                    editor.EditWithGUILayout(new GUIContent("New Serializer"), _newSerializer, _metadata.Enter(1));
                });
            });

            fiEditorGUILayout.Splitter(3);

            if (_currentSerializer.Type == null || _newSerializer.Type == null)
            {
                return;
            }
            if (_currentSerializer.Type == _newSerializer.Type)
            {
                EditorGUILayout.HelpBox("You cannot migrate to the same serializer", MessageType.Error);
                return;
            }

            _selectedMode = GUILayout.SelectionGrid(_selectedMode, new string[] { "Migrate Active Selection", "Migrate Scene Objects", "Migrate Persistent Objects" }, 3);

            if (_selectedMode == 0)
            {
                GameObject[] toMigrate = DisplaySelection();

                if (GUILayout.Button("Run Migration") && CheckAnnotationsPopup())
                {
                    BeforeMigrate();
                    foreach (var obj in toMigrate)
                    {
                        fiSerializerMigrationUtility.MigrateUnityObject(obj, _currentSerializer.Type, _newSerializer.Type);
                    }
                    DisplayPostSerializeMessage();
                }
            }

            else if (_selectedMode == 1)
            {
                DisplayScenesGUI();

                if (SceneObjectSelections == null)
                {
                    SceneObjectSelections = new UnityObjectSelectionGroup(fiSerializerMigrationUtility.GetSceneObjects());
                }

                GUILayout.Label("Scene Objects to Process", EditorStyles.boldLabel);
                SceneObjectSelections.OnGUI();

                GUILayout.FlexibleSpace();

                if (GUILayout.Button("Run Migration", GUILayout.ExpandWidth(true)) && CheckAnnotationsPopup())
                {
                    BeforeMigrate();
                    foreach (var obj in SceneObjectSelections.Selected)
                    {
                        fiSerializerMigrationUtility.MigrateUnityObject(obj, _currentSerializer.Type, _newSerializer.Type);
                    }
                    DisplayPostSerializeMessage();
                }
            }

            else if (_selectedMode == 2)
            {
                if (PersistentObjectSelections == null)
                {
                    PersistentObjectSelections = new UnityObjectSelectionGroup(fiSerializerMigrationUtility.GetPersistentObjects());
                }

                GUILayout.Label("Persistent GameObjects to Process", EditorStyles.boldLabel);
                PersistentObjectSelections.OnGUI();

                if (GUILayout.Button("Run Migration", GUILayout.ExpandWidth(true)) && CheckAnnotationsPopup())
                {
                    BeforeMigrate();
                    foreach (var obj in PersistentObjectSelections.Selected)
                    {
                        fiSerializerMigrationUtility.MigrateUnityObject(obj, _currentSerializer.Type, _newSerializer.Type);
                    }
                    DisplayPostSerializeMessage();
                }
            }
        }
        public void OnGUI()
        {
            try {
                EditorGUIUtility.hierarchyMode = true;
                Type updatedType = _inspectedType;

                GUILayout.Label("Static Inspector", EditorStyles.boldLabel);

                {
                    var label      = new GUIContent("Inspected Type");
                    var typeEditor = PropertyEditor.Get(typeof(Type), null);

                    updatedType = typeEditor.FirstEditor.EditWithGUILayout(label, _inspectedType, Metadata.Enter("TypeSelector"));
                }

                fiEditorGUILayout.Splitter(2);

                if (_inspectedType != null)
                {
                    _inspectorScrollPosition = EditorGUILayout.BeginScrollView(_inspectorScrollPosition);

                    var inspectedType = InspectedType.Get(_inspectedType);
                    foreach (InspectedProperty staticProperty in inspectedType.GetProperties(InspectedMemberFilters.StaticInspectableMembers))
                    {
                        var             editorChain = PropertyEditor.Get(staticProperty.StorageType, staticProperty.MemberInfo);
                        IPropertyEditor editor      = editorChain.FirstEditor;

                        GUIContent label        = new GUIContent(staticProperty.Name);
                        object     currentValue = staticProperty.Read(null);

                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.GetControlRect(GUILayout.Width(8));
                        EditorGUILayout.BeginVertical();

                        GUI.enabled = staticProperty.CanWrite;
                        object updatedValue = editor.EditWithGUILayout(label, currentValue, Metadata.Enter(staticProperty.Name));
                        if (staticProperty.CanWrite)
                        {
                            staticProperty.Write(null, updatedValue);
                        }

                        EditorGUILayout.EndVertical();
                        EditorGUILayout.EndHorizontal();
                    }

                    EditorGUILayout.EndScrollView();
                }

                // For some reason, the type selection popup window cannot force the rest of the
                // Unity GUI to redraw. We do it here instead -- this removes any delay after
                // selecting the type in the popup window and the type actually being displayed.
                if (fiEditorUtility.ShouldInspectorRedraw.Enabled)
                {
                    Repaint();
                }

                if (_inspectedType != updatedType)
                {
                    _inspectedType = updatedType;
                    Repaint();
                }

                EditorGUIUtility.hierarchyMode = false;
            }
            catch (ExitGUIException) { }
            catch (Exception e) {
                Debug.LogError(e);
            }
        }
        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;
            }
        }
예제 #29
0
 public void OverrideInheritedPropertyEditor()
 {
     Assert.IsInstanceOf <OverridenListPropertyEditor>(PropertyEditor.Get(typeof(OverriddenList), null).FirstEditor);
     Assert.IsInstanceOf <OverridenListPropertyEditor <string> >(PropertyEditor.Get(typeof(OverriddenList <string>), null).FirstEditor);
 }
예제 #30
0
 public void EnumTest()
 {
     Assert.IsInstanceOf <EnumPropertyEditor>(PropertyEditor.Get(typeof(CustomEnum), null).FirstEditor);
 }