Associating scriptable objects with gameobjects
I want to make a huge procedurally generated tile map (more than million tiles). It's a map of a cave, tiles might be dirt, diamond, ruby, emerald, etc. Now every mineral has got some properties like how much you should get paid for mining them. Adding a script to every tile obviously is a tad expensive. I settled for storing that data in scriptable objects, but how do I associate the tile with respective scriptable object? Apart from setting the tags of the tiles to e. g. oreDiamond and then in some tile manager singleton ceonnecting every single tile type to every scriptable object? That's a bit of manual work there...
Well assu$$anonymous$$g each tile is a GameObject and as you generate them procedurally you only need to add the Component (Script) that defines each type on the respective prefab.Now in case you don't want this you can have a GameControl script that will pick the tag of the tile and connect it with a Scriptable Object, to do this on the GameControl class you need a reference of the Scriptable Object same way as you refer to other scripts. But then again if you try to instatiate a million objects, in the case it doesn't crash, you ll have a majestic 5 fps max. I would highly advise you to do some reaserch on the procedural generation methods there are several tutorial out there.
Your answer
Follow this Question
Related Questions
How do I place a custom tile? 1 Answer
How do I create tiles that I can add scripts to, and have players interact with? 0 Answers
Unity 2019.1.1f1 Runtime Scriptable Tilebase Not loading problem (Works on Unity Editor) 0 Answers
How to make a mesh tilemap 0 Answers
Applying Normal Maps to Random Tiles 0 Answers