Hi people!
I’m still working with the minimap of the last post.
I changed the way, now how you said I create a texture and I passed to GUI as a Texture2D.
Then I need to calculate the position of any player in the scene and paint it in the texture.
I think that the best way to paint it’s create a transparent texture, position it in the same position in the miniMap, and paint the players.
But how I create a texture on the fly painting the points??
Do you understand my question ???
If something it’s not clear please tell me!
Thank you very much!!!
Creating a texture on the fly is complicated and, more importantly, very slow. I would strongly recommend a render texture or putting the radar with the GUI system.
However, if you insist, it would be something like this:
var texture = new Texture2D(128, 128, TextureFormat.ARGB32, false);
var colors : Color[] = new Color[128*128];
for (y=0;y<texture.height;y++) {
for (x=0;x<texture.width;x++) {
var index : int = y*texture.width + x;
//here is where you do whatever processing you want to do for the texture per pixel
colors[index] = Color.green;
}
}
texture.SetPixels(colors, 0);
texture.Apply();
why don’t you use a dedicated map camera, it is pointing down and parented to your hero character. Also parented to that hero character is a sphere mesh that is coloured and has a layer mask set that only the map camera can see and not the normal game camera. Render texture the map camera and assign it to your map GUI. Position the sphere so that it is the right size in the map. There are a few examples of this being done littered around the forum… I think sometime last year I even posted a project showing this being down for someone.
The beauty of the render texture route is that you then can create custom shaders combined with on the fly opengl plane generating to get nice shaped maps with soft edges etc.
Cheers.