2d-extras icon indicating copy to clipboard operation
2d-extras copied to clipboard

Drawing prefabs at runtime

Open Murop opened this issue 4 years ago • 1 comments

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

Murop avatar Apr 15 '20 19:04 Murop

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.

ChuanXin-Unity avatar Apr 17 '20 01:04 ChuanXin-Unity