Hi, I’ve a bunch of prefabs (meshes) I’m trying to load from a dictionary.
Here’s an add from one of the dictionaries:
public static Dictionary<GripParts, GripPartValues> gripParts = new Dictionary<GripParts, GripPartValues>()
{
{GripParts.Grip1, new GripPartValues(Resources.Load("Prefabs/Items/Weapons/Grips/Grip1") as GameObject, 150f, 40f, "Twohanded", "Zweihander")},
};
When trying to instantiate whichever prefab I try it always comes out as null, “the object you want to insantiate is null”-error.
Custom class called by the dictionary add:
public class GripPartValues
{
GameObject _gripPrefab;
float _gripValue;
float _gripDurability;
string _gripStyle;
string _gripName;
public GameObject GripPrefab
{
get{return _gripPrefab;}
set{_gripPrefab = value;}
}
public float GripValue
{
get{return _gripValue;}
set{_gripValue = value;}
}
public float GripDurability
{
get{return _gripDurability;}
set {_gripDurability = value;}
}
public string GripStyle
{
get{return _gripStyle;}
set{_gripStyle = value;}
}
public string GripName
{
get{return _gripName;}
set{_gripName = value;}
}
public GripPartValues(GameObject gripPrefab, float gripValue, float gripDurability, string gripStyle, string gripName)
{
gripPrefab = _gripPrefab;
gripValue = _gripValue;
gripDurability = _gripDurability;
gripStyle = _gripStyle;
}
}
Resources.Load(“Prefabs/Items/Weapons/Grips/Grip1”)
Folderpath: Assets>Resources>Prefabs>Items>Weapons>Grips>Grip1, Grip2, etc, etc