コード例 #1
0
ファイル: ColorPropertyRM.cs プロジェクト: vault51/Graphics
        public ColorPropertyRM(IPropertyRMProvider controller, float labelWidth) : base(controller, labelWidth)
        {
            m_MainContainer = new VisualElement();

#if USE_MY_COLOR_FIELD
            m_ColorField = new UnityEditor.VFX.UI.VFXColorField(m_Label);
            m_ColorField.OnValueChanged = OnValueChanged;
#else
            m_ColorField = new LabeledField <UnityEditor.UIElements.ColorField, Color>(m_Label);
            m_ColorField.RegisterCallback <ChangeEvent <Color> >(OnValueChanged);
#endif


            m_MainContainer.Add(m_ColorField);
            m_MainContainer.AddToClassList("maincontainer");

            VisualElement fieldContainer = new VisualElement();
            fieldContainer.AddToClassList("fieldContainer");

            m_FloatFields    = new FloatField[4];
            m_TooltipHolders = new VisualElement[4];
            m_FieldParents   = new VisualElement[4];
            for (int i = 0; i < 4; ++i)
            {
                m_FloatFields[i] = new FloatField(names[i]);
                m_FloatFields[i].RegisterCallback <ChangeEvent <float> >(OnValueChanged);

                m_FieldParents[i] = new VisualElement();
                m_FieldParents[i].Add(m_FloatFields[i]);
                m_FieldParents[i].style.flexGrow = 1;
                m_TooltipHolders[i] = new VisualElement();
                m_TooltipHolders[i].style.position = UnityEngine.UIElements.Position.Absolute;
                m_TooltipHolders[i].style.top      = 0;
                m_TooltipHolders[i].style.left     = 0;
                m_TooltipHolders[i].style.right    = 0;
                m_TooltipHolders[i].style.bottom   = 0;
                fieldContainer.Add(m_FieldParents[i]);
            }

            m_MainContainer.Add(fieldContainer);

            m_FloatFields[0].label.AddToClassList("first");

            Add(m_MainContainer);
        }
コード例 #2
0
        public ColorPropertyRM(IPropertyRMProvider controller, float labelWidth) : base(controller, labelWidth)
        {
            m_MainContainer = new VisualElement();

#if USE_MY_COLOR_FIELD
            m_ColorField = new UnityEditor.VFX.UIElements.VFXColorField(m_Label);
            m_ColorField.OnValueChanged = OnValueChanged;
#else
            m_ColorField = new LabeledField <UnityEditor.Experimental.UIElements.ColorField, Color>(m_Label);
            m_ColorField.RegisterCallback <ChangeEvent <Color> >(OnValueChanged);
#endif


            m_MainContainer.Add(m_ColorField);
            m_MainContainer.AddToClassList("maincontainer");

            VisualElement fieldContainer = new VisualElement();
            fieldContainer.AddToClassList("fieldContainer");

            m_RFloatField = new FloatField("R");
            m_RFloatField.RegisterCallback <ChangeEvent <float> >(OnValueChanged);

            m_GFloatField = new FloatField("G");
            m_GFloatField.RegisterCallback <ChangeEvent <float> >(OnValueChanged);

            m_BFloatField = new FloatField("B");
            m_BFloatField.RegisterCallback <ChangeEvent <float> >(OnValueChanged);

            m_AFloatField = new FloatField("A");
            m_AFloatField.RegisterCallback <ChangeEvent <float> >(OnValueChanged);

            fieldContainer.Add(m_RFloatField);
            fieldContainer.Add(m_GFloatField);
            fieldContainer.Add(m_BFloatField);
            fieldContainer.Add(m_AFloatField);

            m_MainContainer.Add(fieldContainer);

            Add(m_MainContainer);
        }