Example #1
0
        public void Apply(Theme theme)
        {
            var isDefault = this.skinset.name == "Default";
            var skin      = this.skin;

            if (!isDefault)
            {
                skin = theme.fontset.Apply(skin);
                theme.palette.Apply(skin);
                ThemeSkin.RemoveHover(skin);
            }
            var styles = skin.GetNamedStyles(false, true, true);

            foreach (var item in this.scopedStyles)
            {
                if (styles.ContainsKey(item.Key))
                {
                    var baseName    = styles[item.Key].name.Parse("[", "]");
                    var replacement = styles[item.Key];
                    var newStyle    = new GUIStyle(replacement).Rename(baseName);
                    this.GetScope().SetVariable(item.Key, newStyle);
                }
            }
        }
Example #2
0
        public void ApplyMain(Theme theme)
        {
            if (this.skin.IsNull())
            {
                return;
            }
            var skin       = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector);
            var isFragment = this.path.Contains("#");
            var isDefault  = this.skinset.name == "Default";
            var main       = this.skin;
            var palette    = theme.palette;

            if (!isDefault)
            {
                main = theme.fontset.Apply(main);
                theme.palette.Apply(main);
                ThemeSkin.RemoveHover(main);
            }
            skin.Use(main, !isFragment, true);
            EditorGUIUtility.GetBuiltinSkin(EditorSkin.Game).Use(skin, !isFragment, true);
            EditorGUIUtility.GetBuiltinSkin(EditorSkin.Scene).Use(skin, !isFragment, true);
            var collabStyle = isDefault ? skin.Get("DropDown").Padding(24, 14, 2, 3) : skin.Get("DropDown");

            Utility.GetUnityType("Toolbar.Styles").GetVariable <GUIStyle>("collabButtonStyle").Use(collabStyle);
            Utility.GetUnityType("AppStatusBar").ClearVariable("background");
            Utility.GetUnityType("SceneRenderModeWindow.Styles").SetVariable("sMenuItem", skin.Get("MenuItem"));
            Utility.GetUnityType("SceneRenderModeWindow.Styles").SetVariable("sSeparator", skin.Get("sv_iconselector_sep"));
            Utility.GetUnityType("GameView.Styles").SetVariable("gizmoButtonStyle", skin.Get("GV Gizmo DropDown"));
            typeof(SceneView).SetVariable <GUIStyle>("s_DropDownStyle", skin.Get("GV Gizmo DropDown"));
            var hostView = Utility.GetUnityType("HostView");

            if (palette.Has("Cursor"))
            {
                skin.settings.cursorColor = palette.Get("Cursor");
            }
            if (palette.Has("Selection"))
            {
                skin.settings.selectionColor = palette.Get("Selection");
            }
            if (palette.Has("Curve"))
            {
                typeof(EditorGUI).SetVariable("kCurveColor", palette.Get("Curve"));
            }
            if (palette.Has("CurveBackground"))
            {
                typeof(EditorGUI).SetVariable("kCurveBGColor", palette.Get("CurveBackground"));
            }
            if (palette.Has("Window"))
            {
                typeof(EditorGUIUtility).SetVariable("kDarkViewBackground", palette.Get("Window"));
                hostView.SetVariable("kViewColor", palette.Get("Window"));
            }
            foreach (var view in Resources.FindObjectsOfTypeAll(hostView))
            {
                view.ClearVariable("background");
            }
            foreach (var window in Locate.GetAssets <EditorWindow>())
            {
                window.minSize = new Vector2(100, 20);
            }
            if (!isDefault)
            {
                Utility.GetUnityType("PreferencesWindow").InstanceVariable("constants").SetVariable("sectionHeader", skin.Get("HeaderLabel"));
            }
            Utility.GetUnityType("BuildPlayerWindow").InstanceVariable("styles").SetVariable("toggleSize", new Vector2(24, 16));
        }