- Home /
Requesting help utilizing resources.load to auto assign rigidbody variable in a class list
I've got a class:
public class ObjectFrequency
{
public Rigidbody prefab;
[HideInInspector]
public float percentageChance;
public float weight;
}
and this list:
public List<ObjectFrequency> prefabList = new List<ObjectFrequency>();
In the past I was manually adding the items to the list, but this is cumbersome and impractical. I would like to use resource.load to load all of my prefabs and add them to a list using my class. They will be stored in the rigidbody prefab variable. The other variables will be calculated and added automatically.
The part I am unsure about is auto assigning the prefab variable based on the prefabs that are loaded. Any tips would be appreciated.
Comment