diff --git a/Editor/Scripts/BaseImporter.cs b/Editor/Scripts/BaseImporter.cs index 413104a..d260e44 100644 --- a/Editor/Scripts/BaseImporter.cs +++ b/Editor/Scripts/BaseImporter.cs @@ -57,6 +57,11 @@ public abstract class TextureImporter : ScriptedImporter { /// in linear color space (sRGB otherwise) /// public bool linear; + + /// + /// If true, an additional sprite asset will be generated. + /// + public bool importAsSprite; // ReSharper disable once NotAccessedField.Local [SerializeField][HideInInspector] @@ -87,6 +92,13 @@ public override void OnImportAsset(AssetImportContext ctx) result.texture.alphaIsTransparency = true; ctx.AddObjectToAsset("result", result.texture); ctx.SetMainObject(result.texture); + + if (importAsSprite) { + var sprite = Sprite.Create(result.texture, new Rect(0, 0, result.texture.width, result.texture.height), new Vector2(50, 50), 100, 0, SpriteMeshType.FullRect); + sprite.name = result.texture.name; + ctx.AddObjectToAsset("sprite", sprite); + } + reportItems = new string[] { }; } else { var errorMessage = ErrorMessage.GetErrorMessage(result.errorCode); diff --git a/Editor/Scripts/KtxImporter.cs b/Editor/Scripts/KtxImporter.cs index fb9ffe7..9cfd734 100644 --- a/Editor/Scripts/KtxImporter.cs +++ b/Editor/Scripts/KtxImporter.cs @@ -22,7 +22,7 @@ namespace KtxUnity { - [ScriptedImporter(0, new []{ ".ktx2" })] + [ScriptedImporter(1, new []{ ".ktx2" })] public class KtxImporter : TextureImporter { protected override TextureBase CreateTextureBase() {