Create sharp vertices rectangle from script

I have a XML file which I read with a C# script in Unity. Based on the data from that file I need to create 2D rectangle of different sizes. This, of course, would need to be created by script. After combing whatever I could find I came to know I would need to use OnGUI legacy functions of Unity. But all examples I see create rectangles with soft edges. How do create rectangle with sharp vertices?

Not sure why you’d use OnGUI; create a mesh using the Mesh class, or else use CanvasRenderer.SetVertices (which I’d recommend).

–Eric

1 Like