From my reading of the object hierarchy, a Tile inherits from TileBase, and TileBase inherits from ScriptableObject.
Therefore you should be able to use ScriptableObject.CreateInstance<>() to make what you want.
In fact, I just verified this works: I created a new Tile and stuck it in my map. And then if you actually want to write it to disk (at editor time obviously), there’s tutorials for how to create the asset, write it, etc.
Hello, thank you for the reply, I am already using set.tile, however set tile is _ set.tile(vector3,tile), what I need is the second parameter. I want to create the tile used for the second parameter of set tile
Thanks! I will try this, I dont need to save the asset, I just need to create a tile and keep the reference so that can be used by set.tile (using a sprite).
Do you think that I could have for example a dummy tile in assets and then instantiate it to clone it? And then set only the new sprite?
Oh absolutely. That is a time-honored mechanism with procedural generation: use the editor for all the hard-to-set-up stuff, then inject just what changes.
Hi I am trying the same thing, I also want to create a tile that can be used as the second argument to the setTile function at runtime. The answer with the Scriptable Objects sounds cool but I am unsure wether this can only work at editor time or if it is possible to even work in a deployed build?
Thanks in advance!
That’s an excellent question but we still prefer that you do not necro-post to old 2019 threads and instead start your own thread.
The answer is that ScriptableObjects are an actual asset that CAN be included in all target builds. It follows the same rules as every other asset and must be referenced either in an included scene or in some other thing within an included scene.