示例#1
0
        public ColorField AddColorField(Color value = new Color(), bool alternate = false, bool secondAlternate = false, bool thirdAlternate = false)
        {
            ColorField el = new ColorField();

            el.value = value;
            el.AddToClassList("list-item-input");
            el.AddToClassList("list-item-color-input");
            AddAlternates(el, alternate, secondAlternate, thirdAlternate);
            el.RegisterValueChangedCallback(e => {
                eventManager.Raise <ListItemInputChange>(new ListItemInputChange(el));
            });
            this.Add(el);
            return(el);
        }
        public VisualElement Build(InspectorDataProxy <Color> proxy)
        {
            var c = proxy.Data;

            m_Field = new ColorField(proxy.Name);
            m_Field.AddToClassList(proxy.Name);
            m_Field.RegisterValueChangedCallback(evt => ColorChanged(proxy, evt));
            return(m_Field);
        }
示例#3
0
        public FoldoutColorField()
        {
            m_ColorField      = new ColorField();
            m_ColorField.name = "field";
            m_ColorField.AddToClassList(k_FieldClassName);
            m_ColorField.RegisterValueChangedCallback((e) => m_MixedValueLine.style.display = DisplayStyle.None);
            header.hierarchy.Add(m_ColorField);

            m_MixedValueLine      = new VisualElement();
            m_MixedValueLine.name = "mixed-value-line";
            m_MixedValueLine.AddToClassList(k_MixedValueLineClassName);
            m_ColorField.Q <IMGUIContainer>().hierarchy.Add(m_MixedValueLine);
        }
        internal override void Apply(VisualElement container)
        {
            /// <sample>
            // Get a reference to the field from UXML and assign it its value.
            var uxmlField = container.Q <ColorField>("the-uxml-field");

            uxmlField.value = Color.red;

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