Пример #1
0
        public override void OnImportAsset(AssetImportContext ctx)
        {
            var        importer = new StyleSheetImporterImpl();
            string     contents = File.ReadAllText(ctx.assetPath);
            StyleSheet asset    = ScriptableObject.CreateInstance <StyleSheet>();

            asset.hideFlags = HideFlags.NotEditable;

            if (importer.Import(asset, contents))
            {
                ctx.AddObjectToAsset("stylesheet", asset);

                // Force the pre processor to rebuild its list of referenced asset paths
                // as paths may have changed with this import.
                StyleSheetAssetPostprocessor.ClearReferencedAssets();

                // Clear the style cache to force all USS rules to recompute
                // and subsequently reload/reimport all images.
                StyleContext.ClearStyleCache();
            }
            else
            {
                foreach (string importError in importer.errors.FormatErrors())
                {
                    Debug.LogError(importError);
                }
            }
        }
Пример #2
0
        public override void OnImportAsset(AssetImportContext ctx)
        {
            StyleSheetImporterImpl styleSheetImporterImpl = new StyleSheetImporterImpl();
            string     contents   = File.ReadAllText(ctx.assetPath);
            StyleSheet styleSheet = ScriptableObject.CreateInstance <StyleSheet>();

            styleSheet.hideFlags = HideFlags.NotEditable;
            if (styleSheetImporterImpl.Import(styleSheet, contents))
            {
                ctx.AddObjectToAsset("stylesheet", styleSheet);
                StyleSheetAssetPostprocessor.ClearReferencedAssets();
                StyleContext.ClearStyleCache();
            }
            else
            {
                foreach (string current in styleSheetImporterImpl.errors.FormatErrors())
                {
                    Debug.LogError(current);
                }
            }
        }