I’m trying to create a list of instances of a custom class. What is the correct way to do this?
In the Awake or Start of that script, make it add itself to either a static list on that class or a list on another object/class.
in C#:
using System.Collections.Generic;
using UnityEngine;
public class CustomType : MonoBehaviour{
public static List<CustomType> instances = new List<CustomType>();
void Awake(){
instances.Add(this);
}
}
Alright, I’ll try that. Cool, thanks.