Hello Unity community!
I’m experimenting with ecs now and Im trying to draw multiple sprites using their meshes as they defined in sprite importer. I’m asking my question here instead of experimental forum section because it is not directly related with Ecs, it is more about sprites and meshes vertex/index buffers.
So far I’ve managed to extract sprite vertices and uvs, generate mesh, and push it to appopriate component, and it is drawn on screen. Everything works, no problem here, except I need to double copy vertex buffer because Sprite class retruns Vector2[ ] for vertices and Mesh class wants Vector3[ ].
I discovered what that vertex buffer is a copy of sprite data. Therefore, my code instantiates 2 copies of vertex buffer and again copies it into Mesh instance. I see it as very poor design. I’d like to know if I able to extract mesh from sprite importer settings without allocations at all in runtime? Okay, I agree to copy my buffer to mesh is required, but is there anything to avoid creating two copies of vertext buffer and one copy of index buffer and uv buffer? Maybe Im missing something obvious?
Thank you!