I’m working on a project using 2D sprites using DOTS. Currently I’m using Texture2DArrays for everything. I think I’ll be able to create everything with maybe 6 different sprite sizes, so that would render thousands of sprites with only 6 materials. I have procedurally generated terrain, characters and objects etc. and all working well so far.
I’m now looking into sprite animations. As there aren’t any 2D sprite animation tools yet for DOTS, I’m thinking of sticking with the Texture2DArrays rather than using sprite sheets, which I think is still way more commonly used. I’d be able to define start and end texture array indices for different animations and then send instructions to the shader to switch between the sprites to play the animation.
I don’t really see any issues, but AFAIK, Texture2DArrays aren’t typically used for this, but maybe just because of the limitation on all sprites being the same size? Appreciate any comments or advice people have on this. Thanks.
IIRC, texture arrays can only be created at run-time in Unity. There is no file format that would import as a texture array. Maybe you could write a tool which saves them as an asset file but I don’t think there is anything out of the box.
Correction: There are flipbook textures which become a texture array, it seems.
Another problem is, that you get a hitch when you create a texture array. So you’d have to create them on the loading screen where it doesn’t matter that much.
In addition to that, texture arrays don’t support texture streaming and texture degradation.
As you said, all sprites would have to have the same size but on the plus side, you don’t have to do u/v calculations and the wrap/repeat filter would work.
Ok thanks. I already had an editor script that creates Texture2D assets and I can get animations and everything working well so far. So it sounds like it would work ok, I’ll see if I run into any performance issues later on on a larger scale. I knew they could do mip maps, but didn’t know about texture streaming, thanks.
I’d say, if you are fine with those limitations, you can use them - especially since flipbooks are imported as texture arrays anyways. Small disclaimer, though, I have no experience with flipbooks, just with texture arrays in general.