Hi,
I want to draw a screen space rect based on a unity rect. Currently I do this :
Vector3[] vertices = new Vector3[4];
vertices[0] = new Vector3(testPos.xMin, testPos.yMin, Camera.current.nearClipPlane);
vertices[1] = new Vector3(testPos.xMin, testPos.yMax, Camera.current.nearClipPlane);
vertices[2] = new Vector3(testPos.xMax, testPos.yMax, Camera.current.nearClipPlane);
vertices[3] = new Vector3(testPos.xMax, testPos.yMin, Camera.current.nearClipPlane);
for (int i = 0; i < 4; i++)
{
vertices _= Camera.current.ViewportToWorldPoint(vertices*);*_
_*}*_
_*mesh.vertices = vertices;*_
_*testMaterial.SetPass(0);*_
_*Graphics.DrawMeshNow(mesh, Matrix4x4.identity);*_
_*```*_
_*<p>This works as expected. However, I would prefer not to set the vertices each time, but rather set the world matrix of the object differently each frame.*_
_*That way I could create the mesh once and use it each time.*_
_*I don't understand exactly how to work it out. Can someone lend a hand?</p>*_
_*<p>Thanks!</p>*_