public static IntegerField ShortField(
     IProperty property,
     ref short value,
     PropertyPath path,
     InspectorVisitorContext visitorContext)
 => Construct <IntegerField, int, short>(property, ref value, path,
                                         visitorContext);
 public static DictionaryElement <TDictionary, TKey, TValue> Foldout <TDictionary, TKey, TValue>(
     IProperty property,
     PropertyPath path,
     InspectorVisitorContext visitorContext)
     where TDictionary : IDictionary <TKey, TValue>
 => ConstructFoldout <DictionaryElement <TDictionary, TKey, TValue> >(
     property, path, visitorContext);
 public static TextField ULongField(
     IProperty property,
     ref ulong value,
     PropertyPath path,
     InspectorVisitorContext visitorContext)
 => Construct <TextField, string, ulong>(property, ref value, path,
                                         visitorContext);
 public InspectorVisitor(PropertyElement bindingElement, T target)
 {
     VisitorContext = new InspectorVisitorContext(bindingElement);
     Target         = target;
     AddAdapter(new NullAdapter <T>(this));
     AddAdapter(new BuiltInAdapter <T>(this));
 }
 static TElement Construct <TElement, TValue>(
     IProperty property,
     ref TValue value,
     PropertyPath path,
     InspectorVisitorContext visitorContext
     )
     where TElement : BaseField <TValue>, new()
 {
     return(Construct <TElement, TValue, TValue>(property, ref value, path,
                                                 visitorContext));
 }
        public static ObjectField ObjectField <TContainer>(
            IProperty <TContainer> property,
            ref UnityEngine.Object value,
            PropertyPath path,
            InspectorVisitorContext visitorContext)
        {
            var element = Construct <ObjectField, UnityEngine.Object, UnityEngine.Object>(
                property,
                ref value,
                path,
                visitorContext,
                field => field.objectType = property.DeclaredValueType());

            return(element);
        }
        static TElement ConstructFoldout <TElement>(
            IProperty property,
            PropertyPath path,
            InspectorVisitorContext visitorContext
            )
            where TElement : Foldout, IContextElement, new()
        {
            var element = ConstructBase <TElement>(property, visitorContext.Parent);

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

            element.SetValueWithoutNotify(UiPersistentState.GetFoldoutState(targetType, path));
            element.RegisterCallback <ChangeEvent <bool> >(evt => UiPersistentState.SetFoldoutState(targetType, path, evt.newValue));
            return(element);
        }
        static TElement Construct <TElement, TFieldType, TValue>(
            IProperty property,
            ref TValue value,
            PropertyPath path,
            InspectorVisitorContext visitorContext,
            Action <TElement> initializer = null
            )
            where TElement : BaseField <TFieldType>, new()
        {
            var element = ConstructBase <TElement, TFieldType>(property, visitorContext.Parent);

            initializer?.Invoke(element);

            SetCallbacks(ref value, path, visitorContext.Root, element);
            visitorContext.Parent.contentContainer.Add(element);
            return(element);
        }
        public static EnumField EnumField <TValue>(
            IProperty property,
            ref TValue value,
            PropertyPath path,
            InspectorVisitorContext visitorContext)
        {
            if (!typeof(TValue).IsEnum)
            {
                throw new ArgumentException();
            }

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

            element.Init(value as Enum);
            return(element);
        }
示例#10
0
 public ParentScope(InspectorVisitorContext context, VisualElement parent)
 {
     m_Context = context;
     m_Parent  = parent;
     m_Context.PushParent(m_Parent);
 }
 public static NullableFoldout <TValue> Foldout <TValue>(
     IProperty property,
     PropertyPath path,
     InspectorVisitorContext visitorContext)
 => ConstructFoldout <NullableFoldout <TValue> >(property, path, visitorContext);
 public static LongField LongField(
     IProperty property,
     ref long value,
     PropertyPath path,
     InspectorVisitorContext visitorContext)
 => Construct <LongField, long>(property, ref value, path, visitorContext);
 public static DoubleField DoubleField(
     IProperty property,
     ref double value,
     PropertyPath path,
     InspectorVisitorContext visitorContext)
 => Construct <DoubleField, double>(property, ref value, path, visitorContext);
 public static IntegerField ByteField(
     IProperty property,
     ref byte value,
     PropertyPath path,
     InspectorVisitorContext visitorContext)
 => Construct <IntegerField, int, byte>(property, ref value, path, visitorContext);
 public static Toggle Toggle(
     IProperty property,
     ref bool value,
     PropertyPath path,
     InspectorVisitorContext visitorContext)
 => Construct <Toggle, bool>(property, ref value, path, visitorContext);
 public static HashSetElement <TSet, TElement> SetFoldout <TSet, TElement>(
     IProperty property,
     PropertyPath path,
     InspectorVisitorContext visitorContext)
     where TSet : ISet <TElement>
 => ConstructFoldout <HashSetElement <TSet, TElement> >(property, path, visitorContext);
 public static FloatField FloatField <TContainer>(
     IProperty <TContainer> property,
     ref float value,
     PropertyPath path,
     InspectorVisitorContext visitorContext)
 => Construct <FloatField, float>(property, ref value, path, visitorContext);
 public static TextField CharField(
     IProperty property,
     ref char value,
     PropertyPath path,
     InspectorVisitorContext visitorContext)
 => Construct <TextField, string, char>(property, ref value, path, visitorContext);
 public static IListElement <TList, TElement> Foldout <TList, TElement>(
     IProperty property,
     PropertyPath path,
     InspectorVisitorContext visitorContext)
     where TList : IList <TElement>
 => ConstructFoldout <IListElement <TList, TElement> >(property, path, visitorContext);