Hello Guest

Author Topic: setTile does not affect TileMap  (Read 4176 times)

Eddi

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
setTile does not affect TileMap
« on: February 06, 2014, 02:53:00 pm »
Hi *,

at moment I try to manipulate my TileMap at runtime, but i don't get it work.
If have a TileMap at 0,0 with a width of 24 and a height of 25. It contains one Layer.
When I try this in a GameObject script, nothing happens:

Code: [Select]

        public tk2dTileMap tileMap;

void Start () {
Debug.Log ("Start called");

int x, y;
tileMap.GetTileAtPosition(new Vector3(2, 2, 0), out x, out y); // x = y = 1
tileMap.SetTile(x, y, 0, 1);
tileMap.SetTile(x, y-1, 0, -1);
tileMap.SetTile(2, 2, 0, 1);
tileMap.SetTile(3, 3, 12, -1);

}

I tried different layer ids from -1 to 12 and nothing works. I also trieed to get the IDs through tileMap.Layers, but I found nothing usefull. I also player with different x,y coordinates, sprite ids and differen layer options.

Any idea?

Thanks in advance  ;)
Eddi
« Last Edit: February 06, 2014, 03:15:40 pm by Eddi »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: setTile does not affect TileMap
« Reply #1 on: February 06, 2014, 09:54:21 pm »
You need to call Build() after calling all your SetTiles to build the changed tile map geometry.

Eddi

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: setTile does not affect TileMap
« Reply #2 on: February 14, 2014, 10:46:39 pm »
So easy :D Sry for the late answer, i was so excised and just forgot it ;)
But better late than never!
Thanks for your help! Works perfectly fine.