Example #1
0
        private void SetPropertyValue(object newValue)
        {
            object val  = StyleDebug.GetComputedStyleValue(m_SelectedElement.computedStyle, m_PropertyInfo.id);
            Type   type = m_PropertyInfo.type;

            if (newValue == null)
            {
                if (type == typeof(StyleBackground))
                {
                    val = new StyleBackground();
                }

                if (type == typeof(StyleFont))
                {
                    val = new StyleFont();
                }

                if (type == typeof(StyleFontDefinition))
                {
                    val = new StyleFontDefinition();
                }
            }
            else if (type == newValue.GetType())
            {
                // For StyleLengthField
                val = newValue;
            }
            else
            {
                if (type == typeof(StyleBackground))
                {
                    val = new StyleBackground(newValue as Texture2D);
                }
                else if (type == typeof(StyleFontDefinition))
                {
                    val = new StyleFontDefinition(newValue);
                }
                else if (val is TextShadow textShadow)
                {
                    if (newValue is Color newColor)
                    {
                        textShadow.color = newColor;
                    }
                    if (newValue is Vector2 newOffset)
                    {
                        textShadow.offset = newOffset;
                    }
                    if (newValue is float newBlur)
                    {
                        textShadow.blurRadius = newBlur;
                    }

                    val = new StyleTextShadow(textShadow);
                }
                else if (type == typeof(StyleEnum <Overflow>) && newValue is OverflowInternal)
                {
                    OverflowInternal newV = (OverflowInternal)newValue;
                    Overflow         v    = newV == OverflowInternal.Hidden ? Overflow.Hidden : Overflow.Visible;
                    val = new StyleEnum <Overflow>(v);
                }
                else if (val is Scale scale && newValue is Vector3 newScale)
                {
                    val = new StyleScale(new Scale(newScale));
                }
Example #2
0
 public BuilderScale(StyleScale styleScale)
     : this(styleScale.value)
 {
 }