示例#1
0
 public static IntegerField ShortField(
     IProperty property,
     ref short value,
     PropertyPath path,
     InspectorVisitor.InspectorContext visitorInspectorContext)
 => Construct <IntegerField, int, short>(property, ref value, path,
                                         visitorInspectorContext);
示例#2
0
 public static DictionaryElement <TDictionary, TKey, TValue> Foldout <TDictionary, TKey, TValue>(
     IProperty property,
     PropertyPath path,
     InspectorVisitor.InspectorContext visitorInspectorContext)
     where TDictionary : IDictionary <TKey, TValue>
 => ConstructFoldout <DictionaryElement <TDictionary, TKey, TValue> >(
     property, path, visitorInspectorContext);
示例#3
0
 public static TextField ULongField(
     IProperty property,
     ref ulong value,
     PropertyPath path,
     InspectorVisitor.InspectorContext visitorInspectorContext)
 => Construct <TextField, string, ulong>(property, ref value, path,
                                         visitorInspectorContext);
        public static IInspector GetAttributeInspector <TValue>(InspectorVisitor.InspectorContext inspectorContext,
                                                                IProperty property, ref TValue value, PropertyPath path)
        {
            if (RuntimeTypeInfoCache <TValue> .CanBeNull && EqualityComparer <TValue> .Default.Equals(value, default))
            {
                return(null);
            }

            if (!RuntimeTypeInfoCache <TValue> .IsContainerType)
            {
                var inspector = InspectorRegistry.GetAttributeInspector <TValue>(property);
                if (null != inspector)
                {
                    inspector.Context = new InspectorContext <TValue>(
                        inspectorContext.Root,
                        path,
                        property,
                        property.GetAttributes()
                        );
                }

                return(inspector);
            }

            using (var scoped = ScopedVisitor <CustomInspectorVisitor <TValue> > .Make())
            {
                var visitor = scoped.Visitor;
                visitor.Target       = InspectorTarget.AttributeInspector;
                visitor.PropertyPath = path;
                visitor.Root         = inspectorContext.Root;
                visitor.Property     = property;
                PropertyContainer.Accept(visitor, ref value);
                return(visitor.Inspector);
            }
        }
示例#5
0
 static TElement Construct <TElement, TValue>(
     IProperty property,
     ref TValue value,
     PropertyPath path,
     InspectorVisitor.InspectorContext visitorInspectorContext
     )
     where TElement : BaseField <TValue>, new()
 {
     return(Construct <TElement, TValue, TValue>(property, ref value, path,
                                                 visitorInspectorContext));
 }
示例#6
0
        public static ObjectField ObjectField(
            IProperty property,
            ref UnityEngine.Object value,
            PropertyPath path,
            InspectorVisitor.InspectorContext visitorInspectorContext)
        {
            var element = Construct <ObjectField, UnityEngine.Object, UnityEngine.Object>(
                property,
                ref value,
                path,
                visitorInspectorContext,
                (field, p) => field.objectType = p.DeclaredValueType());

            return(element);
        }
示例#7
0
        static TElement Construct <TElement, TFieldType, TValue>(
            IProperty property,
            ref TValue value,
            PropertyPath path,
            InspectorVisitor.InspectorContext visitorInspectorContext,
            Action <TElement, IProperty> initializer = null
            )
            where TElement : BaseField <TFieldType>, new()
        {
            var element = ConstructBase <TElement, TFieldType>(property, visitorInspectorContext.Parent);

            initializer?.Invoke(element, property);

            SetCallbacks(ref value, path, visitorInspectorContext.Root, element);
            return(element);
        }
示例#8
0
        static TElement ConstructFoldout <TElement>(
            IProperty property,
            PropertyPath path,
            InspectorVisitor.InspectorContext visitorInspectorContext
            )
            where TElement : Foldout, IContextElement, new()
        {
            var element = ConstructBase <TElement>(property, visitorInspectorContext.Parent);

            element.SetContext(visitorInspectorContext.Root, path);
            var targetType = visitorInspectorContext.Root.GetTargetType();

            element.SetValueWithoutNotify(UiPersistentState.GetFoldoutState(targetType, path));
            element.RegisterCallback <ChangeEvent <bool> >(evt => UiPersistentState.SetFoldoutState(targetType, path, evt.newValue));
            return(element);
        }
示例#9
0
        public static EnumField EnumField <TValue>(
            IProperty property,
            ref TValue value,
            PropertyPath path,
            InspectorVisitor.InspectorContext visitorInspectorContext)
        {
            if (!typeof(TValue).IsEnum)
            {
                throw new ArgumentException();
            }

            var element = Construct <EnumField, Enum, TValue>(
                property,
                ref value,
                path,
                visitorInspectorContext);

            element.Init(value as Enum);
            return(element);
        }
            public bool Visit <TContainer>(InspectorVisitor.InspectorContext inspectorContext, IProperty <TContainer> property, ref KeyValuePair <TKey, TValue> value, PropertyPath path)
            {
                var visitor   = DictionaryElement.GetVisitor();
                var inspector =
                    (IInspector <KeyValuePair <TKey, TValue> >) new KeyValuePairPropertyInspector <TDictionary, TKey, TValue>
                {
                    DictionaryElement = DictionaryElement
                };

                inspector.Context = new InspectorContext <KeyValuePair <TKey, TValue> >(
                    visitor.Context.Root,
                    path,
                    property
                    );

                var customInspector = new CustomInspectorElement(
                    path,
                    inspector,
                    visitor.Context.Root);

                visitor.Context.Parent.contentContainer.Add(customInspector);
                return(true);
            }
示例#11
0
 public static NullableFoldout <TValue> Foldout <TValue>(
     IProperty property,
     PropertyPath path,
     InspectorVisitor.InspectorContext visitorInspectorContext)
 => ConstructFoldout <NullableFoldout <TValue> >(property, path, visitorInspectorContext);
示例#12
0
 public static LongField LongField(
     IProperty property,
     ref long value,
     PropertyPath path,
     InspectorVisitor.InspectorContext visitorInspectorContext)
 => Construct <LongField, long>(property, ref value, path, visitorInspectorContext);
示例#13
0
 public static DoubleField DoubleField(
     IProperty property,
     ref double value,
     PropertyPath path,
     InspectorVisitor.InspectorContext visitorInspectorContext)
 => Construct <DoubleField, double>(property, ref value, path, visitorInspectorContext);
示例#14
0
 public static IntegerField ByteField(
     IProperty property,
     ref byte value,
     PropertyPath path,
     InspectorVisitor.InspectorContext visitorInspectorContext)
 => Construct <IntegerField, int, byte>(property, ref value, path, visitorInspectorContext);
示例#15
0
 public static Toggle Toggle(
     IProperty property,
     ref bool value,
     PropertyPath path,
     InspectorVisitor.InspectorContext visitorInspectorContext)
 => Construct <Toggle, bool>(property, ref value, path, visitorInspectorContext);
示例#16
0
 public static HashSetElement <TSet, TElement> SetFoldout <TSet, TElement>(
     IProperty property,
     PropertyPath path,
     InspectorVisitor.InspectorContext visitorInspectorContext)
     where TSet : ISet <TElement>
 => ConstructFoldout <HashSetElement <TSet, TElement> >(property, path, visitorInspectorContext);
示例#17
0
 public static FloatField FloatField(
     IProperty property,
     ref float value,
     PropertyPath path,
     InspectorVisitor.InspectorContext visitorInspectorContext)
 => Construct <FloatField, float>(property, ref value, path, visitorInspectorContext);
示例#18
0
 public static TextField CharField(
     IProperty property,
     ref char value,
     PropertyPath path,
     InspectorVisitor.InspectorContext visitorInspectorContext)
 => Construct <TextField, string, char>(property, ref value, path, visitorInspectorContext);
示例#19
0
 public static IListElement <TList, TElement> Foldout <TList, TElement>(
     IProperty property,
     PropertyPath path,
     InspectorVisitor.InspectorContext visitorInspectorContext)
     where TList : IList <TElement>
 => ConstructFoldout <IListElement <TList, TElement> >(property, path, visitorInspectorContext);