I'd like to create a short static function which I could call from everywhere to add into a List of Transform (in Unity), here's what I got:
public class MultipableTargetCamera : MonoBehaviour
{
public List<Transform> targets;
public static void AddToCamera(Transform target)
{
targets.Add(target);
}
}
But I get an error message in Unity after saving my script "An object reference is required for the non-static field, method, or property 'MultipableTargetCamera.targets'".
I've tried many things and researched a lot but I can't find any solution that fits my needs.
I want to keep a List of Transform, I dont want use an array or to use a list of strings/ints.
Any ideas?