Example #1
0
        public void OnEnable()
        {
            this.antiAliasing = 4;
            titleContent      = GetLocalizedTitleContent();
            var windowResource = EditorGUIUtility.Load("UXML/AssetStore/AssetStoreWindow.uxml") as VisualTreeAsset;

            if (windowResource != null)
            {
                var root = windowResource.CloneTree();

                var lightStyleSheet      = EditorGUIUtility.Load(EditorUIService.instance.GetUIToolkitDefaultCommonLightStyleSheetPath()) as StyleSheet;
                var assetStoreStyleSheet = EditorGUIUtility.Load("StyleSheets/AssetStore/AssetStoreWindow.uss") as StyleSheet;
                var styleSheet           = CreateInstance <StyleSheet>();
                styleSheet.isUnityStyleSheet = true;

                var resolver = new StyleSheets.StyleSheetResolver();
                resolver.AddStyleSheets(lightStyleSheet, assetStoreStyleSheet);
                resolver.ResolveTo(styleSheet);
                root.styleSheets.Add(styleSheet);

                rootVisualElement.Add(root);
                root.StretchToParentSize();

                visitWebsiteButton.clickable.clicked         += OnVisitWebsiteButtonClicked;
                launchPackageManagerButton.clickable.clicked += OnLaunchPackageManagerButtonClicked;

                alwaysOpenInBrowserToggle.SetValueWithoutNotify(EditorPrefs.GetBool("AlwaysOpenAssetStoreInBrowser", false));

                alwaysOpenInBrowserToggle.RegisterValueChangedCallback(changeEvent =>
                {
                    EditorPrefs.SetBool("AlwaysOpenAssetStoreInBrowser", changeEvent.newValue);
                });
            }
        }
Example #2
0
        internal static StyleSheet ResolveSheets(params StyleSheet[] sheets)
        {
            var resolver = new StyleSheetResolver();

            resolver.AddStyleSheets(sheets);
            return(resolver.ResolvedSheet);
        }
Example #3
0
        internal static StyleSheetResolver ResolveFromSheetsFolder(string sheetsPath, SkinTarget target, StyleSheetResolver.ResolvingOptions options = null, string sheetPostFix = "")
        {
            var sheetFolders = AssetDatabase.GetSubFolders(sheetsPath);

            if (sheetFolders.Length == 0)
            {
                throw new Exception("Cannot find EditorStyles: " + sheetsPath);
            }

            var skinSheetName = string.Format("{0}{1}.uss", target == SkinTarget.Light ? "light" : "dark", sheetPostFix);
            var resolver      = new StyleSheetResolver(options ?? new StyleSheetResolver.ResolvingOptions()
            {
                ThrowIfCannotResolve = true
            });
            var themeDir = sheetsPath + "/_Variables";

            if (Directory.Exists(themeDir))
            {
                var themeSheetPath = themeDir + "/" + skinSheetName;
                resolver.AddStyleSheet(themeSheetPath);
            }

            foreach (var sheetFolder in sheetFolders)
            {
                var commonPath    = sheetFolder + "/" + string.Format("{0}{1}.uss", "common", sheetPostFix);
                var skinSheetPath = sheetFolder + "/" + skinSheetName;
                resolver.AddStyleSheets(commonPath, skinSheetPath);
            }

            return(resolver);
        }
Example #4
0
        internal static StyleSheetResolver ResolveFromSheetsFolder(IEnumerable <string> folders, SkinTarget target, StyleSheetResolver.ResolvingOptions options = null, string sheetPostFix = "")
        {
            var sheetPaths = ConverterUtils.GetSheetPathsFromRootFolders(folders, target, sheetPostFix);

            if (sheetPaths.Length == 0)
            {
                throw new Exception("Cannot find sheets to generate skin");
            }

            var resolver = new StyleSheetResolver(options ?? new StyleSheetResolver.ResolvingOptions()
            {
                ThrowIfCannotResolve = true
            });

            foreach (var sheet in sheetPaths)
            {
                resolver.AddStyleSheets(sheet);
            }

            return(resolver);
        }