I am trying to make a simple Survival game, where you punch stuff and get items from them. I am trying to make a database of items, where I can just find an item by name or id and then either put it in the game or player inventory. I tried making ScriptableObjects, but I don’t know how to access the information from them, when I want to spawn a new object for example. What is the best way to keep a database of different items and access the information from them via Scripts? I also need to save things like Sprites or Meshof the items.
You need to think of ScriptableObjects as more like containers for multiple variables, but not actually a physical unity Object… You can use a base class to define what this structure would hold.
I have recently moved away from the ScriptableObject method to unity’s JSONUtility, this way I can store my objects in flat files and edit or add new objects etc, outside of Unity. Once this is in full implementation for what I need, it can be extendable for modding as well (Just to keep in mind, depending on future functionality concerns of your game)
ScriptableObjects are not easily editable like this outside of the Unity editor. A good review (and freebie projects I believe) would be BurgZerg Arcade - He does a fine job with setting a ScriptableObject database and Editor scripts to Add/Edit items in the DB, I believe its in his first set of RPG tutorials.
Edit: The second RPG tutorial (Unity2017 one) is a little flawed because of how he’s using the getter/setters… Better off following the first one.