2D Toolkit Forum
2D Toolkit => Support => Topic started by: mygamingproject on September 02, 2014, 08:57:18 pm
-
I have a gamescene which has a tilemap, all working nicely for 3 levels.
However, I have added a new level within the same gamescene but the tilemap is slightly different. I don't want to duplicate the gamescene for the sake of about 30% of the tiles so is there a way of hiding a tilemap and showing another? There is no renderer attached to a tilemap so that isnt a default option which made my think because of this it wasnt the right route to take.
What would you suggest?
-
The tilemap renderers are attached to the tilemap render data object. You can show or hide those. That will probably be the easiest way in your situation.
-
Thanks for the tip but how do you reference the renderer and dataobject as have tried tagging
http://imgur.com/YFWSjzB
and then referencing like this:
GameObject tileObj = GameObject.FindGameObjectWithTag("StandardTileMap");
tk2dTileMap tilemap = tileObj.GetComponent<tk2dTileMap>();
tilemap.renderData.renderer.enabled = false;
But get the error:
MissingComponentException: There is no 'Renderer' attached to the "TileMap Render Data" game object, but a script is trying to access it.
You probably need to add a Renderer to the game object "TileMap Render Data". Or your script needs to check if the component is attached before using it.
GameLoop.Awake () (at Assets/Scripts/GameLoop.cs:36)
Have I misunderstood what you mean?
-
Yes, Just enable / disable the gameobject. The tilemap render data is split up into multiple renderers which are children of the root object.
tilemap.SetActive(false);