Ejemplo n.º 1
0
        public override void SelfChange(int change)
        {
            base.SelfChange(change);

            if (controller.depth != 0 && m_Lines == null)
            {
                m_Lines = new VisualElement[controller.depth + 1];

                for (int i = 0; i < controller.depth; ++i)
                {
                    var line = new VisualElement();
                    line.style.width       = 1;
                    line.name              = "line";
                    line.style.marginLeft  = PropertyRM.depthOffset - 2;
                    line.style.marginRight = 0;

                    Insert(3, line);
                    m_Lines[i] = line;
                }
            }


            if (controller.expandable)
            {
                if (controller.expandedSelf)
                {
                    AddToClassList("icon-expanded");
                }
                else
                {
                    RemoveFromClassList("icon-expanded");
                }
                AddToClassList("icon-expandable");

                if (m_ExpandClickable == null)
                {
                    m_ExpandClickable = new Clickable(OnToggleExpanded);
                    m_Icon.AddManipulator(m_ExpandClickable);
                }
            }
            else
            {
                m_Icon.style.backgroundImage = null;
                if (m_ExpandClickable != null)
                {
                    m_Icon.RemoveManipulator(m_ExpandClickable);
                    m_ExpandClickable = null;
                }
            }


            string text    = "";
            string tooltip = null;

            VFXPropertyAttribute.ApplyToGUI(controller.attributes, ref text, ref tooltip);

            this.tooltip = tooltip;
        }
Ejemplo n.º 2
0
        public PropertyRM(IPropertyRMProvider provider, float labelWidth)
        {
            this.AddStyleSheetPathWithSkinVariant("VFXControls");
            this.AddStyleSheetPathWithSkinVariant("PropertyRM");

            m_Provider   = provider;
            m_labelWidth = labelWidth;

            m_IconClickable = new Clickable(OnExpand);

            isDelayed = VFXPropertyAttribute.IsDelayed(m_Provider.attributes);

            if (VFXPropertyAttribute.IsAngle(provider.attributes))
            {
                SetMultiplier(Mathf.PI / 180.0f);
            }

            string labelText    = provider.name;
            string labelTooltip = null;

            VFXPropertyAttribute.ApplyToGUI(provider.attributes, ref labelText, ref labelTooltip);
            m_Label = new Label()
            {
                name = "label", text = labelText
            };
            m_Label.tooltip = labelTooltip;

            if (provider.depth != 0)
            {
                for (int i = 0; i < provider.depth; ++i)
                {
                    VisualElement line = new VisualElement();
                    line.style.width       = 1;
                    line.name              = "line";
                    line.style.marginLeft  = depthOffset + (i == 0 ? -2 : 0);
                    line.style.marginRight = ((i == provider.depth - 1) ? 2 : 0);

                    Add(line);
                }
            }
            m_Icon = new VisualElement()
            {
                name = "icon"
            };
            Add(m_Icon);

            m_Label.style.width = effectiveLabelWidth - provider.depth * depthOffset;
            Add(m_Label);

            AddToClassList("propertyrm");


            RegisterCallback <MouseDownEvent>(OnCatchMouse);

            UpdateExpandable();
        }
Ejemplo n.º 3
0
        public override void SelfChange(int change)
        {
            base.SelfChange(change);

            if (controller.depth != 0 && m_Lines == null)
            {
                m_Lines = new VisualElement[controller.depth + 1];

                for (int i = 0; i < controller.depth; ++i)
                {
                    var line = new VisualElement();
                    line.style.width       = 1;
                    line.name              = "line";
                    line.style.marginLeft  = 0.5f * PropertyRM.depthOffset;
                    line.style.marginRight = PropertyRM.depthOffset * 0.5f;

                    Insert(2, line);
                    m_Lines[i] = line;
                }
            }


            if (controller.expandable)
            {
                if (m_Icons == null)
                {
                    m_Icons = new Texture2D[]
                    {
                        Resources.Load <Texture2D>("VFX/plus"),
                        Resources.Load <Texture2D>("VFX/minus")
                    }
                }
                ;

                m_Icon.style.backgroundImage = controller.expandedSelf ? m_Icons[1] : m_Icons[0];

                m_Icon.AddManipulator(new Clickable(OnToggleExpanded));
            }
            else
            {
                m_Icon.style.backgroundImage = null;
            }


            string text    = "";
            string tooltip = null;

            VFXPropertyAttribute.ApplyToGUI(controller.attributes, ref text, ref tooltip);

            this.tooltip = tooltip;
        }
Ejemplo n.º 4
0
        public void Update()
        {
            Profiler.BeginSample("PropertyRM.Update");

            Profiler.BeginSample("PropertyRM.Update:Angle");
            if (VFXPropertyAttribute.IsAngle(m_Provider.attributes))
            {
                SetMultiplier(Mathf.PI / 180.0f);
            }
            Profiler.EndSample();


            Profiler.BeginSample("PropertyRM.Update:GetValue:");
            object value = m_Provider.value;

            Profiler.EndSample();
            Profiler.BeginSample("PropertyRM.Update:Regex");

            if (value != null)
            {
                string regex = VFXPropertyAttribute.ApplyRegex(m_Provider.attributes, value);
                if (regex != null)
                {
                    value = m_Provider.value = regex;
                }
            }
            Profiler.EndSample();

            UpdateExpandable();

            Profiler.BeginSample("PropertyRM.Update:SetValue");

            SetValue(value);

            Profiler.EndSample();


            Profiler.BeginSample("PropertyRM.Update:Name");

            string text    = ObjectNames.NicifyVariableName(m_Provider.name);
            string tooltip = null;

            VFXPropertyAttribute.ApplyToGUI(m_Provider.attributes, ref text, ref tooltip);
            m_Label.text = text;

            m_Label.tooltip = tooltip;
            Profiler.EndSample();
            Profiler.EndSample();
        }