Best way to create clickable real world map?

Is there a sample or best practice in creating a clickable real world map? Where you can scroll and select countries or even different parts of the countries.

Here is a screenshot of “HOI III” game from Paradox.

alt text


  1. Use a rectangle with(!!) UV mapping on it. (This will be your map)
  2. Use it normal with your diffuse shader or whatever you like to represent it.
  3. Give it a mesh collider!
  4. Have an aspect ratio fitting texture with color encoded shapes (so i.e. 0x00FB0022 would be Berlin area color) - This texture will not be applied anywhere, it is just for looking up the color (and with it the area).
  5. Do a raycast from screen like
  6. Use the UV coordinate to look up the color on your reference texture (the one that was not aplied anywhere).
  7. Look up the found color in your Color<->Area Map
  8. Profit?

You know what area the player clicked.

This method can be used with basically any other shape. You only need to have a color encoded lookup texture fitting to the uv coordinates on the object. You could use this for decals, target zone testing etc. But it has to be a mesh collider, what could be a performance problem for very complex objects. But in this case you will be fine.

The bigger problem is to mark the areas as selected. For this you need to have a transparent (for nicer look) detail overlay texture for your map. Use your reference color texture and copy just that colors shape (defined by its color values) out of it, do 0 alpha on the other pixels, give the non alpha pics the color of your desire and copy it additive on the into the detail overlay texture.

Have fun!

I’d recommend OnMouseEnter / OnMouseExit.

OOH OOH! I did the same thing! So in addition to what dragonlace said or being part of it, this is what I had asked: GUI on click - Questions & Answers - Unity Discussions

and It works perfectly!