I’ve been getting an Object Reference not set to Instance of variable on the last line of this code:
private List<EventScript> events; GameObject newEventObj = Instantiate (Resources.Load ("Event"), myTransform.position, Quaternion.identity) as GameObject; EventScript newEvent = newEventObj.GetComponent<EventScript>(); newEvent.initial = initial; Debug.Log (newEvent.initial); events.Add (newEvent);
but what’s weird, is that the Debug.Log fires off just fine, and gets the appropriate variable. Even the setting of that variable works (the gameObject shows it, so i can see it change).
I’m so confused as to how the object suddenly becomes dereferenced when I try to add it to a list
Thanks for any help!