public static void Dump(Theme theme)
        {
            var path = theme.path.GetDirectory() + "/Dump/";

            File.Create(path);
            foreach (var targetName in new string[2] {
                "s_IconGUIContents", "s_TextGUIContents"
            })
            {
                var target       = "EditorGUIUtility." + targetName;
                var iconContents = typeof(EditorGUIUtility).GetVariable <Hashtable>(targetName);
                var contents     = "".AddLine("(" + target + ")");
                foreach (DictionaryEntry item in iconContents)
                {
                    var content = new ThemeContent();
                    content.name  = item.Key.As <string>();
                    content.value = item.Value.As <GUIContent>();
                    if (!content.value.image.IsNull())
                    {
                        content.value.image.SaveAs(path + content.value.image.name + ".png", true);
                    }
                    contents = contents.AddLine(content.Serialize());
                }
                File.Create(path + target + ".guicontent").Write(contents);
            }
        }
        public static ThemeIconset Import(string path)
        {
            path = path.Replace("\\", "/");
            var iconset = new ThemeIconset();

            iconset.name     = path.GetPathTerm();
            iconset.path     = path;
            iconset.contents = ThemeContent.ImportDefaults(path);
            iconset.contents.AddRange(ThemeContent.Import(path));
            return(iconset);
        }
        public static List <ThemeContent> Import(string path)
        {
            var imported = new List <ThemeContent>();

            foreach (var file in File.FindAll(path + "/*.guicontent", Theme.debug))
            {
                var contents = ThemeContent.DeserializeGroup(file.ReadText());
                foreach (var content in contents)
                {
                    content.Setup(path);
                }
                imported.AddRange(contents);
            }
            return(imported);
        }
Exemple #4
0
        public void OnGUI()
        {
            Theme.disabled = EditorPref.Get <bool>("Zios.Theme.Options.Disabled", false);
            if (ThemeWindow.Inactive())
            {
                return;
            }
            Theme.Update();
            if (ThemeWindow.Inactive())
            {
                return;
            }
            ThemeContent.Monitor();
            var validTheme   = !Theme.active.IsNull() && Theme.active.name != "Default";
            var mouseChanged = this.lastMouse != Event.current.mousePosition;

            Call.Delay(RelativeColor.UpdateSystem, 0.2f, false);
            if (validTheme && mouseChanged)
            {
                this.lastMouse = Event.current.mousePosition;
                float delay = 0;
                if (Theme.hoverResponse == HoverResponse.None)
                {
                    return;
                }
                if (Theme.hoverResponse == HoverResponse.Slow)
                {
                    delay = 0.2f;
                }
                if (Theme.hoverResponse == HoverResponse.Moderate)
                {
                    delay = 0.05f;
                }
                Call.Delay("Redraw", () => {
                    Theme.UpdateColors();
                    var view = Reflection.GetUnityType("GUIView").GetVariable("mouseOverView");
                    if (!view.IsNull())
                    {
                        view.CallMethod("Repaint");
                    }
                }, delay, false);
            }
        }
        public static List <ThemeContent> DeserializeGroup(string data)
        {
            var contents   = new List <ThemeContent>();
            var content    = new ThemeContent();
            var targetPath = "";

            foreach (var line in data.GetLines())
            {
                if (line.Trim().IsEmpty())
                {
                    continue;
                }
                if (line.Contains("("))
                {
                    targetPath = data.Parse("(", ")");
                }
                if (line.ContainsAll("[", "]"))
                {
                    content            = contents.AddNew();
                    content.targetPath = targetPath;
                    content.name       = line.Parse("[", "]");
                }
                else
                {
                    var term  = line.Parse("", "=").Trim();
                    var value = line.Parse("=").Trim();
                    if (term == "image")
                    {
                        content.imageName = value;
                    }
                    else if (term == "text")
                    {
                        content.value.text = value;
                    }
                    else if (term == "tooltip")
                    {
                        content.value.tooltip = value;
                    }
                }
            }
            return(contents);
        }
 public static void Dump()
 {
     ThemeContent.Dump(Theme.active);
 }