Ejemplo n.º 1
0
        public VisualElement Build(InspectorDataProxy <Rect> proxy)
        {
            var c = proxy.Data;

            m_Field = new RectField(proxy.Name);
            m_Field.AddToClassList(proxy.Name);
            SetInputClass(m_Field.Q <FloatField>("unity-x-input"), "x");
            SetInputClass(m_Field.Q <FloatField>("unity-y-input"), "y");
            SetInputClass(m_Field.Q <FloatField>("unity-width-input"), "width");
            SetInputClass(m_Field.Q <FloatField>("unity-height-input"), "height");
            m_Field.RegisterValueChangedCallback(evt => RectChanged(proxy, evt));
            return(m_Field);
        }
Ejemplo n.º 2
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 <RectField>("the-uxml-field");

            uxmlField.value = new Rect(0.0f, 5.5f, 10.1f, 20.3f);

            // Create a new field, disable it, and give it a style class.
            var csharpField = new RectField("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 <Rect> >((evt) =>
            {
                csharpField.value = evt.newValue;
            });
            /// </sample>
        }