public static StyleColor ReadStyleColor(this StyleSheet sheet, StyleValueHandle handle, int specificity)
        {
            Color c = Color.clear;

            if (handle.valueType == StyleValueType.Enum)
            {
                var colorName = sheet.ReadAsString(handle);
                StyleSheetColor.TryGetColor(colorName.ToLower(), out c);
            }
            else
            {
                c = sheet.ReadColor(handle);
            }
            return(new StyleColor(c)
            {
                specificity = specificity
            });
        }
        internal static int GetEnumValue <T>(StyleSheet sheet, StyleValueHandle handle)
        {
            Debug.Assert(handle.valueType == StyleValueType.Enum);

            SheetHandleKey key = new SheetHandleKey(sheet, handle.valueIndex);

            int value;

            if (!s_EnumToIntCache.TryGetValue(key, out value))
            {
                string enumValueName = sheet.ReadEnum(handle).Replace("-", string.Empty);
                object enumValue     = Enum.Parse(typeof(T), enumValueName, true);
                value = (int)enumValue;
                s_EnumToIntCache.Add(key, value);
            }
            Debug.Assert(Enum.GetName(typeof(T), value) != null);
            return(value);
        }
예제 #3
0
        static bool TryGetSourceFromHandle(StyleSheet sheet, StyleValueHandle handle, out Texture2D source)
        {
            source = null;

            switch (handle.valueType)
            {
            case StyleValueType.ResourcePath:
            {
                string path = sheet.ReadResourcePath(handle);

                if (!string.IsNullOrEmpty(path))
                {
                    source = Panel.loadResourceFunc(path, typeof(Texture2D)) as Texture2D;
                }

                if (source == null)
                {
                    Debug.LogWarning(string.Format("Texture not found for path: {0}", path));
                    return(false);
                }
            }
            break;

            case StyleValueType.AssetReference:
            {
                source = sheet.ReadAssetReference(handle) as Texture2D;

                if (source == null)
                {
                    Debug.LogWarning("Invalid texture specified");

                    return(false);
                }
            }
            break;

            default:
                Debug.LogWarning("Invalid value for image source " + handle.valueType);
                return(false);
            }

            return(true);
        }
예제 #4
0
        internal static int GetEnumValue <T>(StyleSheet sheet, StyleValueHandle handle)
        {
            Debug.Assert(handle.valueType == StyleValueType.Enum);

            SheetHandleKey key = new SheetHandleKey(sheet, handle.valueIndex);

            int value = 0;

            if (!s_EnumToIntCache.TryGetValue(key, out value))
            {
                if (TryParseEnum <T>(sheet.ReadEnum(handle), out value))
                {
                    s_EnumToIntCache.Add(key, value);
                    return(value);
                }
            }
            Debug.Assert(Enum.GetName(typeof(T), value) != null);
            return(value);
        }
예제 #5
0
        private static object GetPropertyValue(StyleValueHandle valueHandle, StyleSheet srcSheet)
        {
            object value = null;

            switch (valueHandle.valueType)
            {
            case StyleValueType.Keyword:
                value = srcSheet.ReadKeyword(valueHandle);
                break;

            case StyleValueType.Color:
                value = srcSheet.ReadColor(valueHandle);
                break;

            case StyleValueType.ResourcePath:
                value = srcSheet.ReadResourcePath(valueHandle);
                break;

            case StyleValueType.Enum:
                value = srcSheet.ReadEnum(valueHandle);
                break;

            case StyleValueType.String:
                value = srcSheet.ReadString(valueHandle);
                break;

            case StyleValueType.Float:
                value = srcSheet.ReadFloat(valueHandle);
                break;

            case StyleValueType.Dimension:
                value = srcSheet.ReadDimension(valueHandle);
                break;

            case StyleValueType.AssetReference:
                value = srcSheet.ReadAssetReference(valueHandle);
                break;

            default:
                throw new Exception("Unhandled value type: " + valueHandle.valueType);
            }
            return(value);
        }
        private static StyleKeyword TryReadKeyword(StyleValueHandle handle)
        {
            if (handle.valueType == StyleValueType.Keyword)
            {
                var keyword = (StyleValueKeyword)handle.valueIndex;
                switch (keyword)
                {
                case StyleValueKeyword.Auto:
                    return(StyleKeyword.Auto);

                case StyleValueKeyword.None:
                    return(StyleKeyword.None);

                case StyleValueKeyword.Initial:
                    return(StyleKeyword.Initial);
                }
            }

            return(StyleKeyword.Undefined);
        }
예제 #7
0
        public static Object GetAsset(this StyleSheet styleSheet, StyleValueHandle valueHandle)
        {
            switch (valueHandle.valueType)
            {
            case StyleValueType.ResourcePath:
                var resourcePath = styleSheet.strings[valueHandle.valueIndex];
                var asset        = Resources.Load <Object>(resourcePath);
                return(asset);

            case StyleValueType.Keyword:
                return(null);

#if UNITY_2020_2_OR_NEWER
            case StyleValueType.MissingAssetReference:
                return(null);
#endif
            default:
                return(styleSheet.assets[valueHandle.valueIndex]);
            }
        }
예제 #8
0
        public StyleInt ReadStyleEnum(StyleEnumType enumType, int index)
        {
            StylePropertyValue stylePropertyValue = this.m_Values[this.m_CurrentValueIndex + index];
            StyleValueHandle   handle             = stylePropertyValue.handle;
            bool   flag = handle.valueType == StyleValueType.Keyword;
            string value;

            if (flag)
            {
                StyleValueKeyword svk = stylePropertyValue.sheet.ReadKeyword(handle);
                value = svk.ToUssString();
            }
            else
            {
                value = stylePropertyValue.sheet.ReadEnum(handle);
            }
            int enumIntValue = StylePropertyUtil.GetEnumIntValue(enumType, value);

            return(new StyleInt(enumIntValue));
        }
예제 #9
0
        public static string ToUssString(StyleSheet sheet, UssExportOptions options, StyleValueHandle handle)
        {
            string str = "";

            switch (handle.valueType)
            {
            case StyleValueType.Keyword:
                str = sheet.ReadKeyword(handle).ToString().ToLower();
                break;

            case StyleValueType.Float:
                str = sheet.ReadFloat(handle).ToString(CultureInfo.InvariantCulture.NumberFormat);
                break;

            case StyleValueType.Dimension:
                str = sheet.ReadDimension(handle).ToString();
                break;

            case StyleValueType.Color:
                UnityEngine.Color color = sheet.ReadColor(handle);
                str = ToUssString(color, options.useColorCode);
                break;

            case StyleValueType.ResourcePath:
                str = $"resource(\"{sheet.ReadResourcePath(handle)}\")";
                break;

            case StyleValueType.Enum:
                str = sheet.ReadEnum(handle);
                break;

            case StyleValueType.String:
                str = $"\"{sheet.ReadString(handle)}\"";
                break;

            default:
                throw new ArgumentException("Unhandled type " + handle.valueType);
            }
            return(str);
        }
예제 #10
0
 public static void Apply <T>(this StyleSheet sheet, StyleValueHandle handle, int specificity, LoadResourceFunction loadResourceFunc, ref Style <T> property) where T : UnityEngine.Object
 {
     if (handle.valueType == StyleValueType.Keyword && handle.valueIndex == 5)
     {
         StyleSheetExtensions.Apply <T>((T)((object)null), specificity, ref property);
     }
     else
     {
         string text = sheet.ReadResourcePath(handle);
         if (!string.IsNullOrEmpty(text))
         {
             T t = loadResourceFunc(text, typeof(T)) as T;
             if (t != null)
             {
                 StyleSheetExtensions.Apply <T>(t, specificity, ref property);
             }
             else
             {
                 Debug.LogWarning(string.Format("{0} resource not found for path: {1}", typeof(T).Name, text));
             }
         }
     }
 }
        public static StyleLength ReadStyleLength(this StyleSheet sheet, StyleValueHandle handle, int specificity)
        {
            var keyword = TryReadKeyword(handle);

            StyleLength styleLength = new StyleLength(keyword)
            {
                specificity = specificity
            };

            if (keyword == StyleKeyword.Undefined)
            {
                if (handle.valueType == StyleValueType.Float)
                {
                    styleLength.value = sheet.ReadFloat(handle);
                }
                else
                {
                    Debug.LogError($"Unexpected Length value of type {handle.valueType.ToString()}");
                }
            }

            return(styleLength);
        }
예제 #12
0
        public static void ApplyImage(StyleSheet sheet, StyleValueHandle[] handles, int specificity, ref StyleValue <Texture2D> property)
        {
            Texture2D source = null;

            StyleValueHandle handle = handles[0];

            if (handle.valueType == StyleValueType.Keyword)
            {
                if (handle.valueIndex != (int)StyleValueKeyword.None)
                {
                    Debug.LogWarning("Invalid keyword for image source " + (StyleValueKeyword)handle.valueIndex);
                }
                else
                {
                    // it's OK, we let none be assigned to the source
                }
            }
            else if (TryGetSourceFromHandle(sheet, handle, out source) == false)
            {
                // Load a stand-in picture to make it easier to identify which image element is missing its picture
                source = Panel.loadResourceFunc("d_console.warnicon", typeof(Texture2D)) as Texture2D;
            }
            Apply(source, specificity, ref property);
        }
        private static Function ParseFunction(StyleValueHandle[] sourceValues, StyleSheet srcSheet, StyleValueHandle valueHandle, ref int handleIndex)
        {
            var funcName     = srcSheet.ReadFunctionName(valueHandle);
            var funcArgCount = (int)srcSheet.ReadFloat(sourceValues[++handleIndex]);

            var func      = new Function(funcName);
            var argValues = new List <Value>();

            for (int a = 0; a < funcArgCount; ++a)
            {
                var argHandle = sourceValues[++handleIndex];

                if (argHandle.valueType == StyleValueType.Function)
                {
                    argValues.Add(ParseFunction(sourceValues, srcSheet, argHandle, ref handleIndex));
                }
                else if (argHandle.valueType == StyleValueType.FunctionSeparator)
                {
                    func.args.Add(argValues.ToArray());
                    argValues.Clear();
                }
                else
                {
                    argValues.Add(new Value(argHandle.valueType, GetPropertyValue(argHandle, srcSheet)));
                }
            }

            func.args.Add(argValues.ToArray());

            return(func);
        }
예제 #14
0
 public static string GetString(this StyleSheet styleSheet, StyleValueHandle valueHandle)
 {
     return(styleSheet.strings[valueHandle.valueIndex]);
 }
예제 #15
0
 public static Dimension GetDimension(this StyleSheet styleSheet, StyleValueHandle valueHandle)
 {
     return(styleSheet.ReadDimension(valueHandle));
 }
예제 #16
0
 public static float GetFloat(this StyleSheet styleSheet, StyleValueHandle valueHandle)
 {
     return(styleSheet.ReadFloat(valueHandle));
 }
예제 #17
0
 public static int GetInt(this StyleSheet styleSheet, StyleValueHandle valueHandle)
 {
     return((int)styleSheet.floats[valueHandle.valueIndex]);
 }
예제 #18
0
 public static StyleValueKeyword GetKeyword(this StyleSheet styleSheet, StyleValueHandle valueHandle)
 {
     return(styleSheet.ReadKeyword(valueHandle));
 }
예제 #19
0
 private void LoadProperties()
 {
     this.m_CurrentPropertyIndex = 0;
     this.m_CurrentValueIndex    = 0;
     this.m_Values.Clear();
     this.m_ValueCount.Clear();
     StyleProperty[] properties = this.m_Properties;
     for (int i = 0; i < properties.Length; i++)
     {
         StyleProperty styleProperty          = properties[i];
         int           num                    = 0;
         bool          flag                   = true;
         bool          requireVariableResolve = styleProperty.requireVariableResolve;
         if (requireVariableResolve)
         {
             this.m_Resolver.Init(styleProperty, this.m_Sheet, styleProperty.values);
             int num2 = 0;
             while (num2 < styleProperty.values.Length & flag)
             {
                 StyleValueHandle handle = styleProperty.values[num2];
                 bool             flag2  = handle.IsVarFunction();
                 if (flag2)
                 {
                     StyleVariableResolver.Result result = this.m_Resolver.ResolveVarFunction(ref num2);
                     bool flag3 = result > StyleVariableResolver.Result.Valid;
                     if (flag3)
                     {
                         StyleValueHandle handle2 = new StyleValueHandle
                         {
                             valueType  = StyleValueType.Keyword,
                             valueIndex = 3
                         };
                         this.m_Values.Add(new StylePropertyValue
                         {
                             sheet  = this.m_Sheet,
                             handle = handle2
                         });
                         num++;
                         flag = false;
                     }
                 }
                 else
                 {
                     this.m_Resolver.AddValue(handle);
                 }
                 num2++;
             }
             bool flag4 = flag;
             if (flag4)
             {
                 this.m_Values.AddRange(this.m_Resolver.resolvedValues);
                 num += this.m_Resolver.resolvedValues.Count;
             }
         }
         else
         {
             num = styleProperty.values.Length;
             for (int j = 0; j < num; j++)
             {
                 this.m_Values.Add(new StylePropertyValue
                 {
                     sheet  = this.m_Sheet,
                     handle = styleProperty.values[j]
                 });
             }
         }
         this.m_ValueCount.Add(num);
     }
     this.SetCurrentProperty();
 }
예제 #20
0
 internal static int GetCursorId(StyleSheet sheet, StyleValueHandle handle)
 {
     return(StyleSheetCache.GetEnumValue <MouseCursor>(sheet, handle));
 }
예제 #21
0
        public static string ValueHandleToUssString(StyleSheet sheet, UssExportOptions options, string propertyName, StyleValueHandle handle)
        {
            string str = "";

            switch (handle.valueType)
            {
            case StyleValueType.Keyword:
                str = sheet.ReadKeyword(handle).ToString().ToLower();
                break;

            case StyleValueType.Float:
            {
                var num = sheet.ReadFloat(handle);
                if (num == 0)
                {
                    str = "0";
                }
                else
                {
                    str = num.ToString(CultureInfo.InvariantCulture.NumberFormat);
                    if (IsLength(propertyName))
                    {
                        str += "px";
                    }
                }
            }
            break;

            case StyleValueType.Dimension:
                var dim = sheet.ReadDimension(handle);
                if (dim.value == 0 && !dim.unit.IsTimeUnit())
                {
                    str = "0";
                }
                else
                {
                    str = dim.ToString();
                }
                break;

            case StyleValueType.Color:
                UnityEngine.Color color = sheet.ReadColor(handle);
                str = ToUssString(color, options.useColorCode);
                break;

            case StyleValueType.ResourcePath:
                str = $"resource('{sheet.ReadResourcePath(handle)}')";
                break;

            case StyleValueType.Enum:
                str = sheet.ReadEnum(handle);
                break;

            case StyleValueType.String:
                str = $"\"{sheet.ReadString(handle)}\"";
                break;

            case StyleValueType.MissingAssetReference:
                str = $"url('{sheet.ReadMissingAssetReferenceUrl(handle)}')";
                break;

            case StyleValueType.AssetReference:
                var assetRef = sheet.ReadAssetReference(handle);
                str = GetPathValueFromAssetRef(assetRef);
                break;

            case StyleValueType.Variable:
                str = sheet.ReadVariable(handle);
                break;

            case StyleValueType.ScalableImage:
                var image       = sheet.ReadScalableImage(handle);
                var normalImage = image.normalImage;
                str = GetPathValueFromAssetRef(normalImage);
                break;

            default:
                throw new ArgumentException("Unhandled type " + handle.valueType);
            }
            return(str);
        }
예제 #22
0
 public static string GetEnum(this StyleSheet styleSheet, StyleValueHandle valueHandle)
 {
     return(styleSheet.ReadEnum(valueHandle));
 }
예제 #23
0
 public static StyleValueFunction GetFunction(this StyleSheet styleSheet, StyleValueHandle valueHandle)
 {
     return(styleSheet.ReadFunction(valueHandle));
 }
예제 #24
0
        internal static void RemoveValue(this StyleSheet styleSheet, StyleProperty property, StyleValueHandle valueHandle)
        {
            // Undo/Redo
            Undo.RegisterCompleteObjectUndo(styleSheet, BuilderConstants.ChangeUIStyleValueUndoMessage);

            // We just leave the values in their data array. If we really wanted to remove them
            // we would have to the indicies of all values.

            var valuesList = property.values.ToList();

            valuesList.Remove(valueHandle);
            property.values = valuesList.ToArray();
        }
예제 #25
0
 public static string GetVariable(this StyleSheet styleSheet, StyleValueHandle valueHandle)
 {
     return(styleSheet.ReadVariable(valueHandle));
 }
        internal static int GetCursorId(StyleSheet sheet, StyleValueHandle handle)
        {
            var value = sheet.ReadEnum(handle);

            if (string.Equals(value, "arrow", StringComparison.OrdinalIgnoreCase))
            {
                return((int)MouseCursor.Arrow);
            }
            else if (string.Equals(value, "text", StringComparison.OrdinalIgnoreCase))
            {
                return((int)MouseCursor.Text);
            }
            else if (string.Equals(value, "resize-vertical", StringComparison.OrdinalIgnoreCase))
            {
                return((int)MouseCursor.ResizeVertical);
            }
            else if (string.Equals(value, "resize-horizontal", StringComparison.OrdinalIgnoreCase))
            {
                return((int)MouseCursor.ResizeHorizontal);
            }
            else if (string.Equals(value, "link", StringComparison.OrdinalIgnoreCase))
            {
                return((int)MouseCursor.Link);
            }
            else if (string.Equals(value, "slide-arrow", StringComparison.OrdinalIgnoreCase))
            {
                return((int)MouseCursor.SlideArrow);
            }
            else if (string.Equals(value, "resize-up-right", StringComparison.OrdinalIgnoreCase))
            {
                return((int)MouseCursor.ResizeUpRight);
            }
            else if (string.Equals(value, "resize-up-left", StringComparison.OrdinalIgnoreCase))
            {
                return((int)MouseCursor.ResizeUpLeft);
            }
            else if (string.Equals(value, "move-arrow", StringComparison.OrdinalIgnoreCase))
            {
                return((int)MouseCursor.MoveArrow);
            }
            else if (string.Equals(value, "rotate-arrow", StringComparison.OrdinalIgnoreCase))
            {
                return((int)MouseCursor.RotateArrow);
            }
            else if (string.Equals(value, "scale-arrow", StringComparison.OrdinalIgnoreCase))
            {
                return((int)MouseCursor.ScaleArrow);
            }
            else if (string.Equals(value, "arrow-plus", StringComparison.OrdinalIgnoreCase))
            {
                return((int)MouseCursor.ArrowPlus);
            }
            else if (string.Equals(value, "arrow-minus", StringComparison.OrdinalIgnoreCase))
            {
                return((int)MouseCursor.ArrowMinus);
            }
            else if (string.Equals(value, "pan", StringComparison.OrdinalIgnoreCase))
            {
                return((int)MouseCursor.Pan);
            }
            else if (string.Equals(value, "orbit", StringComparison.OrdinalIgnoreCase))
            {
                return((int)MouseCursor.Orbit);
            }
            else if (string.Equals(value, "zoom", StringComparison.OrdinalIgnoreCase))
            {
                return((int)MouseCursor.Zoom);
            }
            else if (string.Equals(value, "fps", StringComparison.OrdinalIgnoreCase))
            {
                return((int)MouseCursor.FPS);
            }
            else if (string.Equals(value, "split-resize-up-down", StringComparison.OrdinalIgnoreCase))
            {
                return((int)MouseCursor.SplitResizeUpDown);
            }
            else if (string.Equals(value, "split-resize-left-right", StringComparison.OrdinalIgnoreCase))
            {
                return((int)MouseCursor.SplitResizeLeftRight);
            }

            return((int)MouseCursor.Arrow);
        }
예제 #27
0
 public static void SetValue(this StyleSheet styleSheet, StyleValueHandle valueHandle, StyleValueKeyword value)
 {
     throw new InvalidOperationException("Style value cannot be set if its a keyword!");
 }
예제 #28
0
        public static string ValueHandleToUssString(StyleSheet sheet, UssExportOptions options, string propertyName, StyleValueHandle handle)
        {
            string str = "";

            switch (handle.valueType)
            {
            case StyleValueType.Keyword:
                str = sheet.ReadKeyword(handle).ToString().ToLower();
                break;

            case StyleValueType.Float:
            {
                var num = sheet.ReadFloat(handle);
                if (num == 0)
                {
                    str = "0";
                }
                else
                {
                    str = num.ToString(CultureInfo.InvariantCulture.NumberFormat);
                    if (IsLength(propertyName))
                    {
                        str += "px";
                    }
                }
            }
            break;

            case StyleValueType.Dimension:
                var dim = sheet.ReadDimension(handle);
                if (dim.value == 0)
                {
                    str = "0";
                }
                else
                {
                    str = dim.ToString();
                }
                break;

            case StyleValueType.Color:
                UnityEngine.Color color = sheet.ReadColor(handle);
                str = ToUssString(color, options.useColorCode);
                break;

            case StyleValueType.ResourcePath:
                str = $"resource('{sheet.ReadResourcePath(handle)}')";
                break;

            case StyleValueType.Enum:
                str = sheet.ReadEnum(handle);
                break;

            case StyleValueType.String:
                str = $"\"{sheet.ReadString(handle)}\"";
                break;

#if UNITY_2020_2_OR_NEWER
            case StyleValueType.MissingAssetReference:
                str = $"url('{sheet.ReadMissingAssetReferenceUrl(handle)}')";
                break;
#endif
            case StyleValueType.AssetReference:
                var assetRef  = sheet.ReadAssetReference(handle);
                var assetPath = AssetDatabase.GetAssetPath(assetRef);
                if (assetPath.StartsWith("Assets") || assetPath.StartsWith("Packages"))
                {
                    assetPath = "/" + assetPath;
                }
                str = assetRef == null ? "none" : $"url('{assetPath}')";
                break;

            case StyleValueType.Variable:
                str = sheet.ReadVariable(handle);
                break;

            default:
                throw new ArgumentException("Unhandled type " + handle.valueType);
            }
            return(str);
        }
        private void LoadProperties()
        {
            m_CurrentPropertyIndex = 0;
            m_CurrentValueIndex    = 0;
            m_Values.Clear();
            m_ValueCount.Clear();

            foreach (var sp in m_Properties)
            {
                int  count = 0;
                bool valid = true;

                if (sp.requireVariableResolve)
                {
                    // Slow path - Values contain one or more var
                    m_Resolver.Init(sp, m_Sheet, sp.values);
                    for (int i = 0; i < sp.values.Length && valid; ++i)
                    {
                        var handle = sp.values[i];
                        if (handle.IsVarFunction())
                        {
                            var result = m_Resolver.ResolveVarFunction(ref i);
                            if (result != StyleVariableResolver.Result.Valid)
                            {
                                // Resolve failed
                                // When this happens, the computed value of the property is either the property’s
                                // inherited value or its initial value depending on whether the property is inherited or not.
                                // This is the same behavior as the unset keyword so we simply resolve to that value.
                                var unsetHandle = new StyleValueHandle()
                                {
                                    valueType = StyleValueType.Keyword, valueIndex = (int)StyleValueKeyword.Unset
                                };
                                m_Values.Add(new StylePropertyValue()
                                {
                                    sheet = m_Sheet, handle = unsetHandle
                                });
                                ++count;

                                valid = false;
                            }
                        }
                        else
                        {
                            m_Resolver.AddValue(handle);
                        }
                    }

                    if (valid)
                    {
                        m_Values.AddRange(m_Resolver.resolvedValues);
                        count += m_Resolver.resolvedValues.Count;
                    }
                }
                else
                {
                    // Fast path - no var
                    count = sp.values.Length;
                    for (int i = 0; i < count; ++i)
                    {
                        m_Values.Add(new StylePropertyValue()
                        {
                            sheet = m_Sheet, handle = sp.values[i]
                        });
                    }
                }

                m_ValueCount.Add(count);
            }

            SetCurrentProperty();
        }
예제 #30
0
        internal void ApplyRule(StyleSheet registry, int specificity, StyleRule rule, StylePropertyID[] propertyIDs, LoadResourceFunction loadResourceFunc)
        {
            for (int i = 0; i < rule.properties.Length; i++)
            {
                StyleProperty    styleProperty   = rule.properties[i];
                StylePropertyID  stylePropertyID = propertyIDs[i];
                StyleValueHandle handle          = styleProperty.values[0];
                switch (stylePropertyID)
                {
                case StylePropertyID.MarginLeft:
                    registry.Apply(handle, specificity, ref this.marginLeft);
                    break;

                case StylePropertyID.MarginTop:
                    registry.Apply(handle, specificity, ref this.marginTop);
                    break;

                case StylePropertyID.MarginRight:
                    registry.Apply(handle, specificity, ref this.marginRight);
                    break;

                case StylePropertyID.MarginBottom:
                    registry.Apply(handle, specificity, ref this.marginBottom);
                    break;

                case StylePropertyID.PaddingLeft:
                    registry.Apply(handle, specificity, ref this.paddingLeft);
                    break;

                case StylePropertyID.PaddingTop:
                    registry.Apply(handle, specificity, ref this.paddingTop);
                    break;

                case StylePropertyID.PaddingRight:
                    registry.Apply(handle, specificity, ref this.paddingRight);
                    break;

                case StylePropertyID.PaddingBottom:
                    registry.Apply(handle, specificity, ref this.paddingBottom);
                    break;

                case StylePropertyID.BorderLeft:
                    registry.Apply(handle, specificity, ref this.borderLeft);
                    break;

                case StylePropertyID.BorderTop:
                    registry.Apply(handle, specificity, ref this.borderTop);
                    break;

                case StylePropertyID.BorderRight:
                    registry.Apply(handle, specificity, ref this.borderRight);
                    break;

                case StylePropertyID.BorderBottom:
                    registry.Apply(handle, specificity, ref this.borderBottom);
                    break;

                case StylePropertyID.PositionType:
                    registry.Apply(handle, specificity, ref this.positionType);
                    break;

                case StylePropertyID.PositionLeft:
                    registry.Apply(handle, specificity, ref this.positionLeft);
                    break;

                case StylePropertyID.PositionTop:
                    registry.Apply(handle, specificity, ref this.positionTop);
                    break;

                case StylePropertyID.PositionRight:
                    registry.Apply(handle, specificity, ref this.positionRight);
                    break;

                case StylePropertyID.PositionBottom:
                    registry.Apply(handle, specificity, ref this.positionBottom);
                    break;

                case StylePropertyID.Width:
                    registry.Apply(handle, specificity, ref this.width);
                    break;

                case StylePropertyID.Height:
                    registry.Apply(handle, specificity, ref this.height);
                    break;

                case StylePropertyID.MinWidth:
                    registry.Apply(handle, specificity, ref this.minWidth);
                    break;

                case StylePropertyID.MinHeight:
                    registry.Apply(handle, specificity, ref this.minHeight);
                    break;

                case StylePropertyID.MaxWidth:
                    registry.Apply(handle, specificity, ref this.maxWidth);
                    break;

                case StylePropertyID.MaxHeight:
                    registry.Apply(handle, specificity, ref this.maxHeight);
                    break;

                case StylePropertyID.Flex:
                    registry.Apply(handle, specificity, ref this.flex);
                    break;

                case StylePropertyID.BorderWidth:
                    registry.Apply(handle, specificity, ref this.borderWidth);
                    break;

                case StylePropertyID.BorderRadius:
                    registry.Apply(handle, specificity, ref this.borderRadius);
                    break;

                case StylePropertyID.FlexDirection:
                    registry.Apply(handle, specificity, ref this.flexDirection);
                    break;

                case StylePropertyID.FlexWrap:
                    registry.Apply(handle, specificity, ref this.flexWrap);
                    break;

                case StylePropertyID.JustifyContent:
                    registry.Apply(handle, specificity, ref this.justifyContent);
                    break;

                case StylePropertyID.AlignContent:
                    registry.Apply(handle, specificity, ref this.alignContent);
                    break;

                case StylePropertyID.AlignSelf:
                    registry.Apply(handle, specificity, ref this.alignSelf);
                    break;

                case StylePropertyID.AlignItems:
                    registry.Apply(handle, specificity, ref this.alignItems);
                    break;

                case StylePropertyID.TextAlignment:
                    registry.Apply(handle, specificity, ref this.textAlignment);
                    break;

                case StylePropertyID.TextClipping:
                    registry.Apply(handle, specificity, ref this.textClipping);
                    break;

                case StylePropertyID.Font:
                    registry.Apply(handle, specificity, loadResourceFunc, ref this.font);
                    break;

                case StylePropertyID.FontSize:
                    registry.Apply(handle, specificity, ref this.fontSize);
                    break;

                case StylePropertyID.FontStyle:
                    registry.Apply(handle, specificity, ref this.fontStyle);
                    break;

                case StylePropertyID.BackgroundSize:
                    registry.Apply(handle, specificity, ref this.backgroundSize);
                    break;

                case StylePropertyID.WordWrap:
                    registry.Apply(handle, specificity, ref this.wordWrap);
                    break;

                case StylePropertyID.BackgroundImage:
                    registry.Apply(handle, specificity, loadResourceFunc, ref this.backgroundImage);
                    break;

                case StylePropertyID.TextColor:
                    registry.Apply(handle, specificity, ref this.textColor);
                    break;

                case StylePropertyID.BackgroundColor:
                    registry.Apply(handle, specificity, ref this.backgroundColor);
                    break;

                case StylePropertyID.BorderColor:
                    registry.Apply(handle, specificity, ref this.borderColor);
                    break;

                case StylePropertyID.Overflow:
                    registry.Apply(handle, specificity, ref this.overflow);
                    break;

                case StylePropertyID.SliceLeft:
                    registry.Apply(handle, specificity, ref this.sliceLeft);
                    break;

                case StylePropertyID.SliceTop:
                    registry.Apply(handle, specificity, ref this.sliceTop);
                    break;

                case StylePropertyID.SliceRight:
                    registry.Apply(handle, specificity, ref this.sliceRight);
                    break;

                case StylePropertyID.SliceBottom:
                    registry.Apply(handle, specificity, ref this.sliceBottom);
                    break;

                case StylePropertyID.Opacity:
                    registry.Apply(handle, specificity, ref this.opacity);
                    break;

                case StylePropertyID.Custom:
                {
                    if (this.m_CustomProperties == null)
                    {
                        this.m_CustomProperties = new Dictionary <string, CustomProperty>();
                    }
                    CustomProperty value = default(CustomProperty);
                    if (!this.m_CustomProperties.TryGetValue(styleProperty.name, out value) || specificity >= value.specificity)
                    {
                        value.handle      = handle;
                        value.data        = registry;
                        value.specificity = specificity;
                        this.m_CustomProperties[styleProperty.name] = value;
                    }
                    break;
                }

                default:
                    throw new ArgumentException(string.Format("Non exhaustive switch statement (value={0})", stylePropertyID));
                }
            }
        }