Make LoadObjectsOfTypeAll load objects that have not been loaded
Hello! I have an inventory system. And i am trying to load all ScriptableObjects of type "Items" into a list. On the unity docs page for FindObjectsOfTypeAll. It says that FindObjectsOfTypeAll only finds objects that have been loaded. I already have the following code:
public void loadAllItemsInList() {
itemsList = new List<Items> ();
foreach (Items item in Resources.FindObjectsOfTypeAll(typeof(Items)).Cast<Items>()) {
if (item != null) {
itemsList.Add (item as Items);
}
}
}
I have already declared itemsList
This works perfectly. Execpt for one thing. Everytime i open the UnityEditor. I have to load the scriptable objects in some way. I just click on it and now it's loaded. And in the actual game. It doesn't load the items in the list because i have not loaded them when starting the game. How can i fix this?
Your answer
Follow this Question
Related Questions
How could I populate a list with a gameObject during runtime? 0 Answers
How to select the item inside of my inventory slot? (Followed a tutorial into a rut) 0 Answers
Trying to make a click-and-point kind of thing for an escape game. 0 Answers
Retrieving values from list of Scriptable Objects 1 Answer
How do I access variables from Scriptable Objects in an array? 0 Answers