Clickable map

Hello Everyone,

I am starting to explore Unity 3D to use it as a game engine for my project an I do have a question . I am trying to make my first scene in which I will have a rotating globe and I need to have a script that allows me to specifiy certain countries to be clicked on and another scene should be loaded… Pls if anyone can explain to me how to do it in details I will appreciate it

solution 1 - colliders

split a globe model to sub-meshes with countries silhouettes with accuracy you need. now you can catch clicks separately to each country by mapping this meshes to countries

solution 2 - masks

make a alpha-masks for each country. ask should be a texture with alpha-selected country silhouette. on click you just should check clicked pixel (pixel can be gotten by raycast) on each texture and where this pixel is enabled (mask present) - this is your country. this way also lets you highlight countries on mouse hover easily.

this is example of globe texture:

3168-1.jpg

imagine this texture on globe with sphere collider. once we raycast globe from mouse position with hit returned, we got texture coordinates of this hit.

and this is the mask of Russia country:

3169-2.jpg

both textures are (and should be) the same size. now check clicked coordinates from first texture on this texture with transparency only channel. if a pixel in clicked coordinates is white, we clicked Russia country, or else - we clicked somewhere else.