Exemplo n.º 1
0
        public void OnGUI()
        {
            EditorApplication.update -= Theme.ShowWindow;
            Theme.Step();
            Theme.Update();
            ThemeContent.Monitor();
            this.Repaint();
            bool validTheme   = !Theme.active.IsNull() && Theme.active.name != "Default";
            bool mouseChanged = this.lastMouse != Event.current.mousePosition;

            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;
                }
                Utility.DelayCall("Redraw", () => {
                    Theme.UpdateColors();
                    Utility.RepaintAll();
                }, delay, false);
            }
        }
        public static void Dump(Theme theme)
        {
            var path = theme.path.GetDirectory() + "/Dump/";

            FileManager.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());
                }
                FileManager.Create(path + target + ".guicontent").WriteText(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 FileManager.FindAll(path + "/*.guicontent", Theme.debug))
            {
                var contents = ThemeContent.DeserializeGroup(file.GetText());
                foreach (var content in contents)
                {
                    content.Setup(path);
                }
                imported.AddRange(contents);
            }
            return(imported);
        }
        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);
        }
Exemplo n.º 6
0
        public void OnGUI()
        {
            Theme.disabled = Utility.GetPref <bool>("EditorTheme-Disabled", false);
            this.Repaint();
            if (Theme.disabled || !ThemeWindow.setup || EditorApplication.isCompiling || EditorApplication.isUpdating)
            {
                return;
            }
            Theme.Update();
            ThemeContent.Monitor();
            bool validTheme   = !Theme.active.IsNull() && Theme.active.name != "Default";
            bool mouseChanged = this.lastMouse != UnityEvent.current.mousePosition;

            Utility.DelayCall(RelativeColor.UpdateSystem, 0.2f, false);
            if (validTheme && mouseChanged)
            {
                this.lastMouse = UnityEvent.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;
                }
                Utility.DelayCall("Redraw", () =>
                {
                    Theme.UpdateColors();
                    var view = Utility.GetUnityType("GUIView").GetVariable("mouseOverView");
                    if (!view.IsNull())
                    {
                        view.CallMethod("Repaint");
                    }
                }, delay, false);
            }
        }
 public static void Dump()
 {
     ThemeContent.Dump(Theme.active);
 }