Esempio n. 1
0
        public static void AddSkin(StyleSheetBuilderHelper helper, GUISkin skin)
        {
            AddGlobalFont(helper, skin.font);

            // Builtin GUIStyle
            skin.ForEachGUIStyleProperty((name, style) =>
            {
                AddStyle(helper, name.Capitalize(), style);
            });

            // Custom Styles
            foreach (var style in skin.customStyles)
            {
                // GUISkin when instantiated have a null customStyle
                if (style == null)
                {
                    continue;
                }

                var customStyleName = ConverterUtils.ToGUIStyleSelectorName(style.name);
                AddStyle(helper, customStyleName, style);
            }

            AddSettings(helper, skin.settings);
        }
Esempio n. 2
0
        private static void PopulateCustomStyles(StyleSheetCache cache, GUISkin skin, bool throwIfIncomplete = false)
        {
            var customStyleDict = new Dictionary <string, GUIStyle>();

            if (skin.customStyles != null)
            {
                // Add Existing style: ready to be overridden:
                foreach (var customStyle in skin.customStyles)
                {
                    // GUISkin by default adds a null Style
                    if (customStyle != null)
                    {
                        var customStyleName = ConverterUtils.ToGUIStyleSelectorName(customStyle.name);
                        customStyleDict.TryAdd(customStyleName, customStyle);
                    }
                }
            }

            // Look at all the complexSelector tagged as style
            foreach (var kvp in cache.customStyleSelectors)
            {
                GUIStyle customStyle;
                // Check if we are overriding an existing style or if we are creating a new custom style:
                if (!customStyleDict.TryGetValue(kvp.Key, out customStyle))
                {
                    // New style being added:
                    customStyle = new GUIStyle();
                    customStyleDict.Add(kvp.Key, customStyle);
                }
                PopulateStyle(cache, kvp.Value, customStyle, throwIfIncomplete);
            }

            skin.customStyles = customStyleDict.Values.ToArray();
        }