public override void OnImportAsset(AssetImportContext ctx) { var contents = string.Empty; try { contents = File.ReadAllText(ctx.assetPath); } catch (IOException exc) { ctx.LogImportError($"IOException : {exc.Message}"); } finally { var theme = ScriptableObject.CreateInstance <ThemeStyleSheet>(); theme.hideFlags = HideFlags.NotEditable; if (!string.IsNullOrEmpty(contents)) { var importer = new StyleSheetImporterImpl(ctx); importer.disableValidation = disableValidation | isWhitelisted; importer.Import(theme, contents); } var icon = EditorGUIUtility.FindTexture("GUISkin Icon"); ctx.AddObjectToAsset("themeStyleSheet", theme, icon); ctx.SetMainObject(theme); } }
public override void OnImportAsset(AssetImportContext ctx) { isWhitelisted = IsWhiteListed(ctx); string contents = string.Empty; try { contents = File.ReadAllText(ctx.assetPath); } catch (IOException exc) { ctx.LogImportError($"IOException : {exc.Message}"); } finally { StyleSheet asset = ScriptableObject.CreateInstance <StyleSheet>(); asset.hideFlags = HideFlags.NotEditable; if (!string.IsNullOrEmpty(contents)) { var importer = new StyleSheetImporterImpl(ctx); importer.disableValidation = disableValidation | isWhitelisted; importer.Import(asset, contents); } // make sure to produce a style sheet object in all cases ctx.AddObjectToAsset("stylesheet", asset); ctx.SetMainObject(asset); } }