Пример #1
0
        public Vector2Field AddVector2Field(Vector2 value = new Vector2(), bool alternate = false, bool secondAlternate = false, bool thirdAlternate = false)
        {
            Vector2Field el = new Vector2Field();

            el.value = value;
            el.AddToClassList("list-item-input");
            el.AddToClassList("list-item-vector-input");
            AddAlternates(el, alternate, secondAlternate, thirdAlternate);
            el.RegisterValueChangedCallback(e => {
                eventManager.Raise <ListItemInputChange>(new ListItemInputChange(el));
            });
            this.Add(el);
            return(el);
        }
Пример #2
0
        public VisualElement Build(InspectorDataProxy <float2> proxy)
        {
            m_VectorField = new Vector2Field(proxy.Name);
            m_VectorField.AddToClassList(proxy.Name);

            SetInputClass(m_VectorField.Q <FloatField>("unity-x-input"), "x");
            SetInputClass(m_VectorField.Q <FloatField>("unity-y-input"), "y");

            m_VectorField.RegisterValueChangedCallback(evt => ValueChanged(proxy, evt));
            return(m_VectorField);
        }
Пример #3
0
        internal override void Apply(VisualElement container)
        {
            /// <sample>
            // Get a reference to the field from UXML and assign it its value.
            var uxmlField = container.Q <Vector2Field>("the-uxml-field");

            uxmlField.value = new Vector2(23.8f, 12.6f);

            // Create a new field, disable it, and give it a style class.
            var csharpField = new Vector2Field("C# Field");

            csharpField.SetEnabled(false);
            csharpField.AddToClassList("some-styled-field");
            csharpField.value = uxmlField.value;
            container.Add(csharpField);

            // Mirror value of uxml field into the C# field.
            uxmlField.RegisterCallback <ChangeEvent <Vector2> >((evt) =>
            {
                csharpField.value = evt.newValue;
            });
            /// </sample>
        }