Exemplo n.º 1
0
        public static IntegerField CollectionSizeField <TProperty, TContainer, TValue>(
            TProperty property,
            ref TContainer container,
            ref TValue value,
            InspectorVisitorContext visitorContext)
            where TProperty : ICollectionProperty <TContainer, TValue>
        {
            var field = new IntegerField
            {
                name        = "CollectionSize",
                label       = "Size",
                bindingPath = string.Empty,
                isDelayed   = true
            };

            field.SetValueWithoutNotify(property.GetCount(ref container));
            SetTooltip(property.Attributes, field);
            var parent = visitorContext.Parent;

            visitorContext.Parent.contentContainer.Add(field);
            field.RegisterValueChangedCallback(evt =>
            {
                visitorContext.Binding.SetCount(parent, Mathf.Clamp(evt.newValue, 0, int.MaxValue));
            });
            return(field);
        }
Exemplo n.º 2
0
 public static IntegerField ByteField <TProperty, TContainer>(
     TProperty property,
     ref TContainer container,
     ref byte value,
     InspectorVisitorContext visitorContext)
     where TProperty : IProperty <TContainer, byte>
 => Construct <TProperty, IntegerField, int, TContainer, byte>(property, ref container, ref value, visitorContext);
Exemplo n.º 3
0
 public static IntegerField IntField <TProperty, TContainer>(
     TProperty property,
     ref TContainer container,
     ref int value,
     InspectorVisitorContext visitorContext)
     where TProperty : IProperty <TContainer, int>
 => Construct <TProperty, IntegerField, TContainer, int>(property, ref container, ref value, visitorContext);
Exemplo n.º 4
0
 public static TextField TextField <TProperty, TContainer>(
     TProperty property,
     ref TContainer container,
     ref string value,
     InspectorVisitorContext visitorContext)
     where TProperty : IProperty <TContainer, string>
 => Construct <TProperty, TextField, string, TContainer, string>(property, ref container, ref value, visitorContext);
Exemplo n.º 5
0
 public static Toggle Toggle <TProperty, TContainer>(
     TProperty property,
     ref TContainer container,
     ref bool value,
     InspectorVisitorContext visitorContext)
     where TProperty : IProperty <TContainer, bool>
 => Construct <TProperty, Toggle, TContainer, bool>(property, ref container, ref value, visitorContext);
Exemplo n.º 6
0
 public static DoubleField DoubleField <TProperty, TContainer>(
     TProperty property,
     ref TContainer container,
     ref double value,
     InspectorVisitorContext visitorContext)
     where TProperty : IProperty <TContainer, double>
 => Construct <TProperty, DoubleField, TContainer, double>(property, ref container, ref value, visitorContext);
Exemplo n.º 7
0
 public static LongField LongField <TProperty, TContainer>(
     TProperty property,
     ref TContainer container,
     ref long value,
     InspectorVisitorContext visitorContext)
     where TProperty : IProperty <TContainer, long>
 => Construct <TProperty, LongField, TContainer, long>(property, ref container, ref value, visitorContext);
Exemplo n.º 8
0
        public static Foldout Foldout <TProperty, TContainer, TValue>(
            TProperty property,
            ref TContainer container,
            ref TValue value,
            InspectorVisitorContext visitorContext)
            where TProperty : IProperty <TContainer, TValue>
        {
            var propertyName = property.GetName();
            var foldout      = new Foldout
            {
                name        = propertyName,
                bindingPath = propertyName,
            };

            if (property.Attributes?.HasAttribute <InspectorNameAttribute>() ?? false)
            {
                foldout.text = property.Attributes.GetAttribute <InspectorNameAttribute>().displayName;
            }
            else
            {
                foldout.text = propertyName;
            }

            SetTooltip(property.Attributes, foldout);
            visitorContext.Parent.contentContainer.Add(foldout);
            return(foldout);
        }
Exemplo n.º 9
0
 public static FloatField FloatField <TProperty, TContainer>(
     TProperty property,
     ref TContainer container,
     ref float value,
     InspectorVisitorContext visitorContext)
     where TProperty : IProperty <TContainer, float>
 => Construct <TProperty, FloatField, TContainer, float>(property, ref container,
                                                         ref value, visitorContext);
Exemplo n.º 10
0
 public static TElement Construct <TProperty, TElement, TContainer, TValue>(
     TProperty property,
     ref TContainer container,
     ref TValue value,
     InspectorVisitorContext visitorContext
     )
     where TProperty : IProperty <TContainer, TValue>
     where TElement : BaseField <TValue>, new()
 {
     return(Construct <TProperty, TElement, TValue, TContainer, TValue>(property, ref container, ref value, visitorContext));
 }
Exemplo n.º 11
0
        public static ObjectField Construct <TProperty, TContainer, TValue>(
            TProperty property,
            ref TContainer container,
            UnityEngine.Object value,
            InspectorVisitorContext visitorContext
            )
            where TProperty : IProperty <TContainer, TValue>
        {
            var element = ConstructBase <TProperty, TContainer, ObjectField, UnityEngine.Object, TValue>(property);

            visitorContext.Parent.contentContainer.Add(element);
            return(element);
        }
Exemplo n.º 12
0
        public static TElement Construct <TProperty, TElement, TFieldType, TContainer, TValue>(
            TProperty property,
            ref TContainer container,
            ref TValue value,
            InspectorVisitorContext visitorContext
            )
            where TProperty : IProperty <TContainer, TValue>
            where TElement : BaseField <TFieldType>, new()
        {
            var element = ConstructBase <TProperty, TContainer, TElement, TFieldType, TValue>(property);

            visitorContext.Parent.contentContainer.Add(element);
            return(element);
        }
Exemplo n.º 13
0
        public static EnumField EnumField <TProperty, TContainer, TValue>(
            TProperty property,
            ref TContainer container,
            ref TValue value,
            InspectorVisitorContext visitorContext)
            where TProperty : IProperty <TContainer, TValue>
        {
            if (!typeof(TValue).IsEnum)
            {
                throw new ArgumentException();
            }
            var name    = property.GetName();
            var element = new EnumField(value as Enum)
            {
                bindingPath = name
            };

            SetNames(property, element);
            SetTooltip(property.Attributes, element);
            visitorContext.Parent.contentContainer.Add(element);
            return(element);
        }
Exemplo n.º 14
0
 public InspectorVisitor(PropertyElement bindingElement, T target)
 {
     VisitorContext = new InspectorVisitorContext(bindingElement);
     Target         = target;
 }
 public ParentScope(InspectorVisitorContext context, VisualElement parent)
 {
     m_Context = context;
     m_Parent  = parent;
     m_Context.PushParent(m_Parent);
 }