Example #1
0
        public bool TryGetValue(CustomStyleProperty <Color> property, out Color value)
        {
            if (m_CustomProperties != null && m_CustomProperties.TryGetValue(property.name, out var customProp))
            {
                var handle = customProp.handle;
                switch (handle.valueType)
                {
                case StyleValueType.Enum:
                {
                    var colorName = customProp.sheet.ReadAsString(handle);
                    return(StyleSheetColor.TryGetColor(colorName.ToLower(), out value));
                }

                case StyleValueType.Color:
                {
                    if (customProp.sheet.TryReadColor(customProp.handle, out value))
                    {
                        return(true);
                    }
                    break;
                }

                default:
                    LogCustomPropertyWarning(property.name, StyleValueType.Color, customProp);
                    break;
                }
            }

            value = Color.clear;
            return(false);
        }
Example #2
0
        public bool TryGetValue(CustomStyleProperty <string> property, out string value)
        {
            if (m_CustomProperties != null && m_CustomProperties.TryGetValue(property.name, out var customProp))
            {
                value = customProp.sheet.ReadAsString(customProp.handle);
                return(true);
            }

            value = string.Empty;
            return(false);
        }
Example #3
0
        public bool TryGetValue(CustomStyleProperty <bool> property, out bool value)
        {
            if (m_CustomProperties != null && m_CustomProperties.TryGetValue(property.name, out var customProp))
            {
                value = customProp.sheet.ReadKeyword(customProp.handle) == StyleValueKeyword.True;
                return(true);
            }

            value = false;
            return(false);
        }
Example #4
0
        public bool TryGetValue(CustomStyleProperty <float> property, out float value)
        {
            if (TryGetValue(property.name, StyleValueType.Float, out var customProp))
            {
                if (customProp.sheet.TryReadFloat(customProp.handle, out value))
                {
                    return(true);
                }
            }

            value = 0f;
            return(false);
        }
            public bool TryGetValue <T>(CustomStyleProperty <T> property, out T value) where T : Object
            {
                if (m_CustomProperties != null && m_CustomProperties.TryGetValue(property.name, out var customProp))
                {
                    if (customProp.sheet.TryReadAssetReference(customProp.handle, out Object objValue))
                    {
                        value = objValue as T;
                        return(value != null);
                    }
                }

                value = null;
                return(false);
            }
            public bool TryGetValue(CustomStyleProperty <int> property, out int value)
            {
                if (TryGetValue(property.name, StyleValueType.Float, out var customProp))
                {
                    if (customProp.sheet.TryReadFloat(customProp.handle, out var tmp))
                    {
                        value = (int)tmp;
                        return(true);
                    }
                }

                value = 0;
                return(false);
            }
Example #7
0
        public bool TryGetValue(CustomStyleProperty <Color> property, out Color value)
        {
            StylePropertyValue customProp;

            if (TryGetValue(property.name, StyleValueType.Color, out customProp))
            {
                if (customProp.sheet.TryReadColor(customProp.handle, out value))
                {
                    return(true);
                }
            }

            value = Color.clear;
            return(false);
        }
Example #8
0
        public bool TryGetValue(CustomStyleProperty <VectorImage> property, out VectorImage value)
        {
            if (m_CustomProperties != null && m_CustomProperties.TryGetValue(property.name, out var customProp))
            {
                var source = new ImageSource();
                if (StylePropertyReader.TryGetImageSourceFromValue(customProp, dpiScaling, out source) && source.vectorImage != null)
                {
                    value = source.vectorImage;
                    return(true);
                }
            }

            value = null;
            return(false);
        }
Example #9
0
        public bool TryGetValue(CustomStyleProperty <Texture2D> property, out Texture2D value)
        {
            StylePropertyValue customProp;

            if (m_CustomProperties != null && m_CustomProperties.TryGetValue(property.name, out customProp))
            {
                var source = new ImageSource();
                if (StylePropertyReader.TryGetImageSourceFromValue(customProp, dpiScaling, out source) && source.texture != null)
                {
                    value = source.texture;
                    return(true);
                }
            }

            value = null;
            return(false);
        }
Example #10
0
 public bool Equals(CustomStyleProperty <T> other)
 {
     return(name == other.name);
 }