Пример #1
0
 public static void InvertTextColors(this GUISkin current, float intensityCompare, float difference = 1.0f)
 {
     foreach (var style in current.GetStyles())
     {
         foreach (var state in style.GetStates())
         {
             state.InvertTextColor(intensityCompare, difference);
         }
     }
 }
Пример #2
0
 public static void RemoveHover(GUISkin skin)
 {
     if (Theme.hoverResponse != HoverResponse.None)
     {
         return;
     }
     foreach (var style in skin.GetStyles())
     {
         style.hover = style.normal;
     }
 }
Пример #3
0
 public static GUIStyle Get(this GUISkin current, string name)
 {
     if (GUISkinExtension.cachedStyles.AddNew(current).ContainsKey(name))
     {
         return(GUISkinExtension.cachedStyles[current][name]);
     }
     foreach (var style in current.GetStyles())
     {
         if (style.name == name)
         {
             GUISkinExtension.cachedStyles[current][name] = style;
             return(style);
         }
     }
     return(null);
 }
Пример #4
0
 public static void SaveFonts(this GUISkin current, string path, bool includeBuiltin = true)
 {
     foreach (var style in current.GetStyles())
     {
         if (!style.font.IsNull())
         {
             string assetPath = FileManager.GetPath(style.font);
             string savePath  = path + "/" + assetPath.GetPathTerm();
             if (!includeBuiltin && assetPath.Contains("unity editor resources"))
             {
                 continue;
             }
             if (!FileManager.Exists(savePath))
             {
                 AssetDatabase.CopyAsset(assetPath, savePath);
             }
         }
     }
 }
Пример #5
0
 public static void SaveBackgrounds(this GUISkin current, string path, bool includeBuiltin = true)
 {
     foreach (var style in current.GetStyles())
     {
         foreach (var state in style.GetStates())
         {
             if (!state.background.IsNull())
             {
                 string assetPath = FileManager.GetPath(state.background);
                 string savePath  = path + "/" + state.background.name + ".png";
                 if (!includeBuiltin && assetPath.Contains("unity editor resources"))
                 {
                     continue;
                 }
                 if (!FileManager.Exists(savePath))
                 {
                     state.background.SaveAs(savePath, true);
                 }
             }
         }
     }
 }
Пример #6
0
        public static Dictionary <string, GUIStyle> GetNamedStyles(this GUISkin current, bool includeStandard = true, bool includeCustom = true, bool trimBaseName = false)
        {
            var data   = new Dictionary <string, GUIStyle>();
            var styles = current.GetStyles(includeStandard, includeCustom);

            for (int index = 0; index < styles.Length; ++index)
            {
                var style = styles[index];
                var name  = trimBaseName ? style.name.Split("[")[0].Trim() : style.name;
                if (name.IsEmpty())
                {
                    data["Element " + index] = style;
                    continue;
                }
                while (data.ContainsKey(name))
                {
                    name       = name.ToLetterSequence();
                    style.name = name;
                }
                data[name] = style;
            }
            return(data);
        }
Пример #7
0
        //=================================
        // Dynamics
        //=================================
        public void Apply(GUISkin skin)
        {
            if (this.swap.Count < 1)
            {
                this.Build();
            }
            var styles = skin.GetStyles();

            foreach (var style in styles)
            {
                foreach (var state in style.GetStates())
                {
                    foreach (var swap in this.swap)
                    {
                        var color = swap.Value.value;
                        if (state.textColor.Matches(swap.Key, false))
                        {
                            state.textColor = state.textColor.a == 0 ? color : new Color(color.r, color.g, color.b, state.textColor.a);
                        }
                    }
                }
            }
            foreach (var swap in this.swap)
            {
                var color    = swap.Value.value;
                var settings = skin.settings;
                if (settings.selectionColor.Matches(swap.Key, false))
                {
                    settings.selectionColor = settings.selectionColor.a == 0 ? color : new Color(color.r, color.g, color.b, settings.selectionColor.a);
                }
                if (settings.cursorColor.Matches(swap.Key, false))
                {
                    settings.cursorColor = settings.cursorColor.a == 0 ? color : new Color(color.r, color.g, color.b, settings.cursorColor.a);
                }
            }
        }