Hey guys,
So I wanted to create a system for my items, where it loads all the prefabs from the folder into a generated array list. I can’t seem to get it to work.
using UnityEngine;
using System.Collections;
public class Items : MonoBehaviour
{
public enum ItemType
{
Potion,
Sword,
Quest_Item,
Shoes
};
public enum Effects
{
Health,
Mana,
};
public ItemType _itemType;
public Effects _effects;
public string ItemName= "";
public string ItemDescription = "";
public GameObject[] _items;
void Start()
{
_items = Resources.LoadAll<GameObject> ("Prefabs/Items");
}
}
Any help would be appreciated ![]()
Is your "Prefabs/Items" folder located in the Resources foulder? Because Resources.Load/LoadAll searches in the Resources folder. Otherwise try _items = (GameObject[]) Resources.LoadAll ("Prefabs/Items"); // cast to GameObject ref.
– JScotty