atteneder / KtxUnity

Load KTX and Basis Universal textures at runtime
Apache License 2.0
218 stars 42 forks source link

Further unity integration #2

Closed Saticmotion closed 2 years ago

Saticmotion commented 5 years ago

So the last couple of days I've been looking into further Unity integration, so that we could assign a basis texture to a texture field in the inspector, and show previews in the editor.

Previews are possible as far as I can tell, but will have quite the overhead. The editor would have to transcode every single texture to a format the editor can handle (Is there a format that's supported on all 3 editor platforms?).

Convincing unity that a basis file is a texture seems to be impossible. That part of the engine is all in the cpp side, so I don't see a way to do this. If further integration is not possible, users will always have to assign textures through code.

Any ideas?

atteneder commented 5 years ago

I did not make anything like this before, but maybe this is a solution: https://docs.unity3d.com/Manual/ScriptedImporters.html

Saticmotion commented 5 years ago

Scripted Importers can't tell the engine that a certain file is actually a texture. There's also the related TextureGenerator, but that also has no way to tell unity that a file it can't read as a texture is actually a texture. Maybe I should try pinging some Unity devs on Twitter! I've seen someone ask a unity dev about something similar a while back, but it was solved via DM.

Saticmotion commented 5 years ago

I got confirmation from a Unity dev, and from someone trying to do the same thing with a different texture format, that what I want to do is not possible at this time. But Unity devs are working on APIs that will make it possible in the future. So for now we can't provide real integration of .basis in the editor.

hybridherbst commented 2 years ago

I believe this can be closed since there's now a ScriptedImporter for .ktx2 in this package at least

atteneder commented 2 years ago

I agree, we got something now. Not saying the current ScriptedImporter is perfect/complete, but I'd rather open new issues with a clear scope.