Hello Guest

Author Topic: Any way to increase TileMap.Build performance?  (Read 4352 times)

Neeko

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 59
    • View Profile
    • Overdeveloped
Any way to increase TileMap.Build performance?
« on: May 03, 2014, 10:20:53 pm »
As the title says, other than decreasing the chunk size (I'm currently set to 8x8), is there anything else I can do to help increase the performance of performing a TileMap.Build? I'm currently deploying to Ouya, and there's a bad, noticeable hitch when I call TileMap.Build to change some platformer tiles.

If not, what would be a good alternative to change the look of a tile? When a player dies, I want the tile to get bloody (similar effect to Super Meat Boy). Perhaps overlaying another sprite on the tile, instead of changing it?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Any way to increase TileMap.Build performance?
« Reply #1 on: May 04, 2014, 10:41:18 am »
The best thing to do is to probably split it up into 2 tilemaps, the static one with larger partitions and the smaller for the overlays. That should be considerably faster as it will only be touching a few sprites. Also, try tk2d 2.5 beta, it may be a bit faster due to MarkAsDynamic on the meshes - this seems to be random what platform it helps on and I haven't tried on Ouya, so definitely worth a try here.

Neeko

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 59
    • View Profile
    • Overdeveloped
Re: Any way to increase TileMap.Build performance?
« Reply #2 on: May 04, 2014, 03:39:28 pm »
I upgraded to 2.5 beta, added a new, smaller tile map to the scene that's sized to overlay the platform tiles on the main tile map.

I'm now getting several of these messages on startup

Destroying object multiple times. Don't use DestroyImmediate on the same object in OnDisable or OnDestroy.
UnityEngine.Object:DestroyImmediate(Object)
tk2dUtil:DestroyImmediate(Object) (at Assets/TK2DROOT/tk2d/Code/tk2dUtil.cs:50)
tk2dRuntime.TileMap.SpriteChunk:DestroyGameData(tk2dTileMap) (at Assets/TK2DROOT/tk2dTileMap/Code/tk2dTileMapChunks.cs:54)
tk2dRuntime.TileMap.Layer:DestroyGameData(tk2dTileMap) (at Assets/TK2DROOT/tk2dTileMap/Code/tk2dTileMapChunks.cs:405)
tk2dTileMap:OnDestroy() (at Assets/TK2DROOT/tk2dTileMap/Code/tk2dTileMap.cs:174)

Seems to be one for every chunk in the new tile map.

I also get this message when I try to call SetTile on the smaller tile map

IndexOutOfRangeException: Array index is out of range.
tk2dRuntime.TileMap.Layer.FindChunkAndCoordinate (Int32 x, Int32 y, System.Int32& offset) (at Assets/TK2DROOT/tk2dTileMap/Code/tk2dTileMapChunks.cs:372)
tk2dRuntime.TileMap.Layer.GetRawTileValue (Int32 x, Int32 y, System.Int32& value) (at Assets/TK2DROOT/tk2dTileMap/Code/tk2dTileMapChunks.cs:384)
tk2dRuntime.TileMap.Layer.GetTileFlags (Int32 x, Int32 y) (at Assets/TK2DROOT/tk2dTileMap/Code/tk2dTileMapChunks.cs:428)
tk2dRuntime.TileMap.Layer.SetTile (Int32 x, Int32 y, Int32 tile) (at Assets/TK2DROOT/tk2dTileMap/Code/tk2dTileMapChunks.cs:450)
tk2dTileMap.SetTile (Int32 x, Int32 y, Int32 layer, Int32 tile) (at Assets/TK2DROOT/tk2dTileMap/Code/tk2dTileMap.cs:721)

Neeko

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 59
    • View Profile
    • Overdeveloped
Re: Any way to increase TileMap.Build performance?
« Reply #3 on: May 04, 2014, 04:24:22 pm »
I'm actually going to go a different route with this. I'm going to create blood splatter prefabs that I'll just pool and position over the tile map, rather than manipulate the tile map directly. The performance is much better and I'll be able to animate the blood splatter as well.