Example #1
0
        private void ApplyCustomStyleProperty(StyleSheet sheet, StyleProperty styleProperty, int specificity)
        {
            if (m_CustomProperties == null)
            {
                m_CustomProperties = new Dictionary <string, CustomPropertyHandle>();
            }

            CustomPropertyHandle customProp = default(CustomPropertyHandle);

            if (!m_CustomProperties.TryGetValue(styleProperty.name, out customProp) || specificity >= customProp.specificity)
            {
                customProp.handles     = styleProperty.values;
                customProp.data        = sheet;
                customProp.specificity = specificity;
                m_CustomProperties[styleProperty.name] = customProp;
            }
        }
        private bool TryGetValue(string propertyName, StyleValueType valueType, out CustomPropertyHandle customPropertyHandle)
        {
            customPropertyHandle = new CustomPropertyHandle();
            if (m_CustomProperties != null && m_CustomProperties.TryGetValue(propertyName, out customPropertyHandle))
            {
                // CustomProperty only support one value
                var handle = customPropertyHandle.value.handle;
                if (handle.valueType != valueType)
                {
                    Debug.LogWarning(string.Format("Trying to read value as {0} while parsed type is {1}", valueType, handle.valueType));
                    return(false);
                }

                return(true);
            }

            return(false);
        }
        private void ApplyCustomStyleProperty(StylePropertyReader reader)
        {
            if (m_CustomProperties == null)
            {
                m_CustomProperties = new Dictionary <string, CustomPropertyHandle>();
            }

            var styleProperty = reader.property;
            var specificity   = reader.specificity;

            CustomPropertyHandle customProp = default(CustomPropertyHandle);

            if (!m_CustomProperties.TryGetValue(styleProperty.name, out customProp) || specificity >= customProp.specificity)
            {
                // Custom property only support one value
                customProp.value       = reader.GetValue(0);
                customProp.specificity = specificity;
                m_CustomProperties[styleProperty.name] = customProp;
            }
        }