How to create a Rounded Box dynamically?

I want to dynamically create some solid color, possibly with some transparency, but nothing more rounded rects on my gui, but I’m not sure how this can be done or if its possible. I would like this to be dynamic, and not need to create anything in photoshop first, can anyone point me in the right direction?

Yes, it is possible. You’ll have to create a new Texture2D:
http://docs.unity3d.com/412/Documentation/ScriptReference/Texture2D.Texture2D.html

Then you’ll have to set the color (and alpha eventually) for each pixel:
http://docs.unity3d.com/412/Documentation/ScriptReference/Texture2D.SetPixels.html
http://docs.unity3d.com/412/Documentation/ScriptReference/Texture2D.SetPixels32.html

Remember to call Apply at the end:
http://docs.unity3d.com/412/Documentation/ScriptReference/Texture2D.Apply.html

Note that you’ll have to do the calculations yourself for the color and alpha to create the rounded corners shape :wink:

Also check how 9-slices work and how to use them in Unity with GUIStyle…