I'm currently trying to render sprites in Unity without using a sprite renderer component.
So far using Graphics.DrawMesh() I have this:
public void Draw(Sprite sprite, Vector3 pos) {
Material mat = new Material(spriteMaterial) {
mainTexture = sprite.texture
};
Mesh mesh = new Mesh() {
vertices = Array.ConvertAll(sprite.vertices, x => (Vector3)x),
triangles = Array.ConvertAll(sprite.triangles, x => (int)x),
uv = sprite.uv
};
Graphics.DrawMesh(mesh, Matrix4x4.TRS(pos, Quaternion.identity, sprite.bounds.size), mat, 0);
}
Everything was working fine except after doing a test with a about hundred or so sprites my fps went down to around 30.
So the question is, is this normal? If not, what potential bottlenecks could there be?