Hello Guest

Author Topic: Intended method to instantiate a tile map prefab?  (Read 3553 times)

GarthSmith

  • Newbie
  • *
  • Posts: 6
  • Games. Math. Code.
    • View Profile
    • Garth Smith's Website
Intended method to instantiate a tile map prefab?
« on: August 21, 2013, 10:02:54 pm »
Hello!

Is it intended behavior that ForceBuild() is required to display a tile map? This is how I am getting a tile map to display.

Code: [Select]
public tk2dTileMap m_tileMapPrefab; // Pre-configured tile map.

void Start() {
    tk2dTileMap instantiatedTileMap = Instantiate(m_tileMapPrefab) as tk2dTileMap; // Creates a GameObject, but tile map is not rendered.
    instantiatedTileMap.ForceBuild(); // Tile map is now visible.
}

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Intended method to instantiate a tile map prefab?
« Reply #1 on: August 21, 2013, 10:10:36 pm »
More or less. Why are you instantiating a tilemap? Its pretty expensive to build it - its usually better to simply load the tilemap scene in additively to your current scene...

GarthSmith

  • Newbie
  • *
  • Posts: 6
  • Games. Math. Code.
    • View Profile
    • Garth Smith's Website
Re: Intended method to instantiate a tile map prefab?
« Reply #2 on: August 21, 2013, 10:35:03 pm »
We plan on having about 100 smallish "rooms" in our game world. As the player travels, we will be destroying the old room and instantiating a new one.

We hope to keep this room-changing time to under a second. We have a transition that occurs between room changes that should hopefully hide any load times. If performance becomes a problem, I'll have the scenes and LoadLevelAdditiveAsync method as a backup plan.

Thanks for the reply!
« Last Edit: August 21, 2013, 10:39:18 pm by GarthSmith »