2D Toolkit Forum

2D Toolkit => Support => Topic started by: GarthSmith on August 21, 2013, 10:02:54 pm

Title: Intended method to instantiate a tile map prefab?
Post by: GarthSmith 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.
}
Title: Re: Intended method to instantiate a tile map prefab?
Post by: unikronsoftware 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...
Title: Re: Intended method to instantiate a tile map prefab?
Post by: GarthSmith 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!