public Vector3PropertyRM(IPropertyRMProvider controller, float labelWidth) : base(controller, labelWidth)
        {
            bool isColor = VFXPropertyAttribute.IsColor(m_Provider.attributes);

            if (isColor)
            {
                m_ColorField = new VFXColorField(m_Label);
                m_ColorField.OnValueChanged = OnColorValueChanged;
                m_ColorField.showAlpha      = false;
                m_VectorField = new VFXVector3Field();
                m_VectorField.RegisterCallback <ChangeEvent <Vector3> >(OnValueChanged);
                var mainContainer = new VisualElement()
                {
                    name = "mainContainer"
                };
                mainContainer.AddToClassList("maincontainer");

                mainContainer.Add(m_ColorField);
                mainContainer.Add(m_VectorField);
                Add(mainContainer);
                m_VectorField.AddToClassList("fieldContainer");
            }
            else
            {
                var labeledField = new VFXLabeledField <VFXVector3Field, Vector3>(m_Label);
                m_VectorField = labeledField.control;
                labeledField.RegisterCallback <ChangeEvent <Vector3> >(OnValueChanged);
                Add(labeledField);
                labeledField.AddToClassList("fieldContainer");
            }
        }
Example #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);
        }