Unity-Technologies / 2d-extras

Fun 2D Stuff that we'd like to share!
Other
1.55k stars 343 forks source link

Drawing prefabs at runtime #194

Open ghost opened 4 years ago

ghost commented 4 years ago

Dear friends, i am currently working on a road construction system and i found out that this asset is just perfect for me. In the Scene view i am able to create my roads, intersections, tcross, curves and stuff everything works fine. Now i have to make this work at runtime too, so the player can draw his roads at runtime. How am i able to do this? Thanks

ChuanXin-Unity commented 4 years ago

You can make use of the Tilemap Scripting APIs (https://docs.unity3d.com/ScriptReference/Tilemaps.Tilemap.html) to add Tiles to the Tilemap during Runtime, for example using Tilemap.SetTile to add or remove your Road Tiles to the Tilemap. The Tilemap Editor itself is using these same APIs to add and remove Tiles in the Unity Editor.