Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Editor/Scripts/BaseImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ public abstract class TextureImporter : ScriptedImporter {
/// in linear color space (sRGB otherwise)
/// </summary>
public bool linear;

/// <summary>
/// If true, an additional sprite asset will be generated.
/// </summary>
public bool importAsSprite;

// ReSharper disable once NotAccessedField.Local
[SerializeField][HideInInspector]
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Editor/Scripts/KtxImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

namespace KtxUnity
{
[ScriptedImporter(0, new []{ ".ktx2" })]
[ScriptedImporter(1, new []{ ".ktx2" })]
public class KtxImporter : TextureImporter {

protected override TextureBase CreateTextureBase() {
Expand Down