Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Interactive World map

Discussion in 'UGUI & TextMesh Pro' started by Epilol, Oct 19, 2015.

  1. Epilol

    Epilol

    Joined:
    Jul 21, 2015
    Posts:
    85
    Hello guys,
    I'm trying to make a interactive/clickable map for my game: once the player selects one country, the camera zooms to that area and show the different levels he can play.

    I was thinking about making buttons with the shape of the countries, but I'm having problems with the anchors. If I modify the size of the window, everything moves around.

    bug.jpg

    Is there a way to fix this or should I try another method?

    thanks a lot in advance :)
     
  2. DanielFF

    DanielFF

    Joined:
    Aug 29, 2012
    Posts:
    41
    HI,
    I think you should work with relative sizes and postions. You could have a default map (800x600 for example) and then adjuste positions and sizes of countrys, like this:

    country1Postion.x = (default_country1Po.x / default_MapWidth) * current_MapWidth

    Also, I dont know if buttons would be a good idea, because they have regular area. Masks would be better, where the mask would be a texture in which each country have a pixel color. Thus, identifying the pixel color in the position of the click, you know in which country the user clicked

    I hope this help.
     
    SimonDarksideJ, Senshi and Epilol like this.
  3. Epilol

    Epilol

    Joined:
    Jul 21, 2015
    Posts:
    85
    It works, thanks a lot :)