I am curious about what the formal workflow is for custom asset types, or custom data formats.
Suppose I’ve made my own file format for indexed 4-bit (16 color) graphics, where each byte contains two pixels of image data. Let’s call it “16C” format (e.g., a file might be called image.16C). How do I go about loading such a file into Unity? I don’t want to simply convert the file into a .PNG and represent it as a Texture2D. I want my own class to represent it. Is this possible?
Ideally, I would like Unity Editor’s asset folder to recognize my special format, and perhaps even produce a thumbnail representing it (I expect I’d have to write my own thumbnail rendering function).
Is this even possible? Do I use ScriptableWizard? Or perhaps ScriptableObject? Or something else?
How to implement full texture inspector (like default one)? Or maybe there is a way to teach builtin TextureImporter to load a custom image format? It’s editor is already implemented.
@
I don’t have an exact answer for you but two possible approaches:
Use reflection to get the built in importer and inspector, use those and add your custom stuff on top
In the quite new UI toolkit Sample project I’ve noticed a drop down menu at the top of the texture importer to select between the regular texture importer, the psd / psb importer and an overriden version of the psd importer… As I just recently discovered that myself I haven’t really looked at the files yet to figure out how to use this feature but override importers sounds exactly like what you are looking for.
I’ve used that CreateEditor in the past succesfully for extending built in component inspectors but indeed in this case (maybe even in general) the override approach from the ui sample project seems like the best way to pursue.