Quick question (at least, I hope it’s quick):
This is my first time using scriptable objects, so I’m new to this stuff.
I have a BaseItem : ScriptableObject script.
Then I have a Weapons: BaseItem script, a QuestItems : BaseItem script, etc., all with BaseItem info and also some unique information.
Now, when populating the inventory, I’ve watched video upon video. I like the one presented in Unity’s Adventure Game Tutorial, but it’s set up for only populating the inventory list with the BaseItem. How do I get a master inventory list controller that’ll add any kind of item? Do I need to go a whole different route? (If so, please point me in the right direction.)
The simplified inventory from the Adventure Game tutorial that I was trying to adapt:
(note: using C#)
public class Inventory: MonoBehaviour {
public const int numItemSlots = 4;
public Image[] itemImages = new Image[numItemSlots];
public BaseItem[] items = new BaseItem[numItemSlots];
public void AddItem(BaseItem itemToAdd)
{
for(int i = 0; i < items.Length; i++)
{
if(items *== null)*
{
items = itemToAdd;
itemImages*.sprite = itemToAdd.sprite;*
itemImages*.enabled = true;*
return;
}
}
}