Skip to main content
added 524 characters in body
Source Link

Theoretically you could do what you are asking for, however it may run differently and give you different results on different devices.

The Unity way of doing things would be to create a prefab game object that has a circle graphic and a text object attached to it and when you instantiate it you can change the size & color of the circle (even stretch it to an oval if you want) and change the size, text & color of the text object.

If you want to go down that path and need more details let me know what you need more details on.

If you have your heart set on drawing your own texture you will basically need to create an empty texture and then set the color of each pixel via code.

var texture = new Texture2D(2, 2, TextureFormat.ARGB32, false);

texture.SetPixel(0, 0, Color(1.0, 1.0, 1.0, 0.5));
texture.SetPixel(1, 0, Color.red);
texture.SetPixel(0, 1, Color.green);
texture.SetPixel(1, 1, Color.blue);

texture.Apply();

You would of course want to create an entire class to create texture object so you didn't have to do it by hand and there is probably something on the asset store that already does all that, so maybe start there.

Theoretically you could do what you are asking for, however it may run differently and give you different results on different devices.

The Unity way of doing things would be to create a prefab game object that has a circle graphic and a text object attached to it and when you instantiate it you can change the size & color of the circle (even stretch it to an oval if you want) and change the size, text & color of the text object.

If you want to go down that path and need more details let me know what you need more details on.

Theoretically you could do what you are asking for, however it may run differently and give you different results on different devices.

The Unity way of doing things would be to create a prefab game object that has a circle graphic and a text object attached to it and when you instantiate it you can change the size & color of the circle (even stretch it to an oval if you want) and change the size, text & color of the text object.

If you want to go down that path and need more details let me know what you need more details on.

If you have your heart set on drawing your own texture you will basically need to create an empty texture and then set the color of each pixel via code.

var texture = new Texture2D(2, 2, TextureFormat.ARGB32, false);

texture.SetPixel(0, 0, Color(1.0, 1.0, 1.0, 0.5));
texture.SetPixel(1, 0, Color.red);
texture.SetPixel(0, 1, Color.green);
texture.SetPixel(1, 1, Color.blue);

texture.Apply();

You would of course want to create an entire class to create texture object so you didn't have to do it by hand and there is probably something on the asset store that already does all that, so maybe start there.

Source Link

Theoretically you could do what you are asking for, however it may run differently and give you different results on different devices.

The Unity way of doing things would be to create a prefab game object that has a circle graphic and a text object attached to it and when you instantiate it you can change the size & color of the circle (even stretch it to an oval if you want) and change the size, text & color of the text object.

If you want to go down that path and need more details let me know what you need more details on.