I have some editor scripts where I am loading all assets at a path. So I am running this code not during play mode.
The following code works:
public void LoadAllCards()
{
Object[] assets = Resources.LoadAll("ScriptableObjects/Cards", typeof(Object)) as Object[];
Debug.Log(assets);
foreach (Object card in assets)
{
Debug.Log(card);
}
}
The following code does NOT work. assets is NULL always in this case. M_Card is just a ScriptableObject.
public void LoadAllCards()
{
cards = new List<M_Card>();
M_Card[] assets = Resources.LoadAll("ScriptableObjects/Cards", typeof(M_Card)) as M_Card[];
Debug.Log(assets);
foreach (M_Card card in assets)
{
Debug.Log(card);
}
}
Do you know why Resources.LoadAll is working just fine if I use generic objects (and when I later cast it to M_Card, it works just fine), but is not working when I specify a specific class (like ScriptableObject or M_Card)?