Question by
Tesorero204 · Jan 17, 2020 at 05:07 PM ·
scripting beginnerscriptableobjectresources.load
Resources.Load not loading instances of a scriptableObject
Hi! On this void, I am using a deserialized data class called MoveInventoryData, which holds a string[]
called moveList, that contains the name of each Move in the list moves. Then, I'm using Resources.Load<Move>
to find ScriptableObjects (moves) with each name to add to a List of Moves. however, it is not loading anything, although the saving and loading mechanisms are working. Please help!
public List<Move> moves;
void InventoryLoad()
{
MoveInventoryData data = InventorySaver.LoadMoveInventory();
moves = new List<Move>();
for (int i = 0; i < data.moveList.Length; i++)
{
Move moveToAdd = Resources.Load(data.moveList[i]) as Move;
moves.Add(moveToAdd);
}
}
Comment
Here it is: [System.Serializable] public class $$anonymous$$oveInventoryData { public string[] moveList;
public $$anonymous$$oveInventoryData($$anonymous$$oveInventory mi)
{
List<string> moveNames = new List<string>();
for (int i = 0; i < mi.moves.Count; i++)
{
moveNames.Add(mi.moves[i].name);
}
moveList = moveNames.ToArray();
}
}
I wasn't asking for the definition of the class, but the content of the array (i.e the strings)
Your answer
![](https://koobas.hobune.stream/wayback/20220612221704im_/https://answers.unity.com/themes/thub/images/avi.jpg)