How to access SpriteRenderer's Mesh

Hi
How to access spriteRenderer’s mesh so it can be changed in runtime . I want to create a 2d wavy water using Mesh class but it can be assigned a srpite .
thanks for your help.

FYI you can get the .triangles and .uv

1 Answer

1

No it is not possible afaik. And you would not achieve what you want I think. SpriteRenderer generate complex unregular meshes. You would not be able to transform them.

Also mesh transformation is very expensive if you are not doing it in shader.

thanks for your reply . but I don't think mesh transformation is expensive . in my case , it took 0.2 (1.2%) milliseconds to calculate for a mesh with 2500 vertex.

Ok, but than imho you'll need a regular grid mesh to make a wavy transformation which is not provided by sprite renderer. It is simplier to make it by hand. Sprite shoul be converted to Material and loaded as texture.