#Tilemap basics

1 messages · Page 1 of 1 (latest)

fading glacier
#

I am trying to generate a basic map with Tilemap, programmatically. I created a GameController gameobject with references to the Tilemap tilemap and a Tile tile. However, I cannot attach my CustomTile script that derives from Tile to a GameObject (bc it doesn't derive from Monobehavior). So I can't figure out how to get a reference to my CustomTile prefab with the Tile script on it.

Therefore in GameController.Start() I don't know how I can call Tilemap.setTile() without a reference to my CustomTile prefab. I am looking into scriptable objects but I'm not sure if thats the right idea 🤔

#

example code i found on google:

#

from the unity docs on ScriptableTiles:

Create instances of your new class using ScriptableObject.CreateInstance<YOUR_TILE_CLASS>(). You may convert this new instance to an Asset in the Editor in order to use it repeatedly by calling AssetDatabase.CreateAsset().

#

i think this might work but it seems to be using a different approach from the one a lot of the answers are suggesting i use (getting a reference to Tile from the editor)