Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Tile Map Get tile from tilemap from Click.

Discussion in '2D Experimental Preview' started by YarikX, Nov 2, 2018.

  1. YarikX

    YarikX

    Joined:
    Jan 16, 2016
    Posts:
    2
    Help. I want to get tilemap tile. But I have more than one tilemap. Help. I want to receive coordinates when clicked so that later I can get a tile using the GetTile function.

    upload_2018-11-2_16-34-0.png
     

    Attached Files:

  2. qqqbbb

    qqqbbb

    Joined:
    Jan 13, 2016
    Posts:
    96
    Code (CSharp):
    1. Vector3 mousePos = MainCamera.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0f));
    2. int tilePosX = Mathf.FloorToInt(mousePos.x);
    3. int tilePosY = Mathf.FloorToInt(mousePos.y);