StartCoroutine() causes NullReferenceException when scenes are changed.
Exception: NullReferenceException: Object reference not set to an instance of an object FlowEvent+d__34.MoveNext () (at Assets/Scripts/Hex/Imports/Death Of A Pet/FlowEvent.cs:266) UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at :0) UnityEngine.MonoBehaviour:StartCoroutine(String) FlowEvent:runEvent() (at Assets/Scripts/Hex/Imports/Death Of A Pet/FlowEvent.cs:227) FlowEvent:OnTriggerEnter(Collider) (at Assets/Scripts/Hex/Imports/Death Of A Pet/FlowEvent.cs:397)
FlowEvent.cs
LINE 266 ... if (lightsPRE.Length > 0)
FlowEvent.cs
LINE 227... StartCoroutine(IRunEvent());
FlowEvent.cs
LINE 396 ... private void OnTriggerEnter(Collider other)
LINE 397 ... {
None of this makes sense to me because I everything worked perfect this morning and I did not change a thing. Also, this exception only occurs when I load the scene and dont run with the scene already loaded. If I have the scene already open and play then I get no exceptions. And the exception pointed to line 397, which is literally just a "{".
Your answer
Follow this Question
Related Questions
The order of the sound played 0 Answers
StartCouroutine doesn't work with If statements? 1 Answer
StartCoroutine(getLocation()); 0 Answers
StopCoroutine not working. 0 Answers
After stop coroutine it resumes its task when I call start coroutine 1 Answer