playMaker

Author Topic: NullReferenceException while calling OnLevelWasLoaded()  (Read 4290 times)

pedroathumanspot

  • Playmaker Newbie
  • *
  • Posts: 11
NullReferenceException while calling OnLevelWasLoaded()
« on: April 18, 2013, 10:10:35 AM »
Hi everyone,

We're almost pulling our hairs out on this one. We are getting a (pretty nasty) NullReferenceException while loading a Scene/Level that occurs when OnLevelWasLoaded is called. We already checked (and double checked) all of our references on all the scene FSMs and they're all good. We are passing some GameObjects with a script that has a DontDestroyOnLoad() though - I don't know if this helps or has some impact.

Here's the output of the error in question:
Code: [Select]
NullReferenceException: Object reference not set to an instance of an object
HutongGames.PlayMaker.Fsm.ProcessEvent (HutongGames.PlayMaker.FsmEvent fsmEvent, HutongGames.PlayMaker.FsmEventData eventData)
HutongGames.PlayMaker.Fsm.BroadcastEvent (HutongGames.PlayMaker.FsmEvent fsmEvent, Boolean excludeSelf)
HutongGames.PlayMaker.Fsm.Event (HutongGames.PlayMaker.FsmEventTarget eventTarget, HutongGames.PlayMaker.FsmEvent fsmEvent)
HutongGames.PlayMaker.Actions.SendEvent.OnEnter () (at Assets/PlayMaker/Actions/SendEvent.cs:39)
HutongGames.PlayMaker.FsmState.OnEnter ()
HutongGames.PlayMaker.Fsm.EnterState (HutongGames.PlayMaker.FsmState state)
HutongGames.PlayMaker.Fsm.SwitchState (HutongGames.PlayMaker.FsmState toState)
HutongGames.PlayMaker.Fsm.UpdateStateChanges ()
HutongGames.PlayMaker.Fsm.Start ()
HutongGames.PlayMaker.Fsm.ProcessEvent (HutongGames.PlayMaker.FsmEvent fsmEvent, HutongGames.PlayMaker.FsmEventData eventData)
HutongGames.PlayMaker.Fsm.BroadcastEvent (HutongGames.PlayMaker.FsmEvent fsmEvent, Boolean excludeSelf)
HutongGames.PlayMaker.Fsm.Event (HutongGames.PlayMaker.FsmEventTarget eventTarget, HutongGames.PlayMaker.FsmEvent fsmEvent)
HutongGames.PlayMaker.Actions.SendEvent.OnEnter () (at Assets/PlayMaker/Actions/SendEvent.cs:39)
HutongGames.PlayMaker.FsmState.OnEnter ()
HutongGames.PlayMaker.Fsm.EnterState (HutongGames.PlayMaker.FsmState state)
HutongGames.PlayMaker.Fsm.SwitchState (HutongGames.PlayMaker.FsmState toState)
HutongGames.PlayMaker.Fsm.UpdateStateChanges ()
HutongGames.PlayMaker.Fsm.Start ()
HutongGames.PlayMaker.Fsm.ProcessEvent (HutongGames.PlayMaker.FsmEvent fsmEvent, HutongGames.PlayMaker.FsmEventData eventData)
HutongGames.PlayMaker.Fsm.BroadcastEvent (HutongGames.PlayMaker.FsmEvent fsmEvent, Boolean excludeSelf)
HutongGames.PlayMaker.Fsm.Event (HutongGames.PlayMaker.FsmEventTarget eventTarget, HutongGames.PlayMaker.FsmEvent fsmEvent)
HutongGames.PlayMaker.Actions.SendEvent.OnEnter () (at Assets/PlayMaker/Actions/SendEvent.cs:39)
HutongGames.PlayMaker.FsmState.OnEnter ()
HutongGames.PlayMaker.Fsm.EnterState (HutongGames.PlayMaker.FsmState state)
HutongGames.PlayMaker.Fsm.SwitchState (HutongGames.PlayMaker.FsmState toState)
HutongGames.PlayMaker.Fsm.UpdateStateChanges ()
HutongGames.PlayMaker.Fsm.Start ()
HutongGames.PlayMaker.Fsm.ProcessEvent (HutongGames.PlayMaker.FsmEvent fsmEvent, HutongGames.PlayMaker.FsmEventData eventData)
HutongGames.PlayMaker.Fsm.BroadcastEvent (HutongGames.PlayMaker.FsmEvent fsmEvent, Boolean excludeSelf)
HutongGames.PlayMaker.Fsm.Event (HutongGames.PlayMaker.FsmEventTarget eventTarget, HutongGames.PlayMaker.FsmEvent fsmEvent)
HutongGames.PlayMaker.Actions.SendEvent.OnEnter () (at Assets/PlayMaker/Actions/SendEvent.cs:39)
HutongGames.PlayMaker.FsmState.OnEnter ()
HutongGames.PlayMaker.Fsm.EnterState (HutongGames.PlayMaker.FsmState state)
HutongGames.PlayMaker.Fsm.SwitchState (HutongGames.PlayMaker.FsmState toState)
HutongGames.PlayMaker.Fsm.UpdateStateChanges ()
HutongGames.PlayMaker.Fsm.Start ()
HutongGames.PlayMaker.Fsm.ProcessEvent (HutongGames.PlayMaker.FsmEvent fsmEvent, HutongGames.PlayMaker.FsmEventData eventData)
HutongGames.PlayMaker.Fsm.Event (HutongGames.PlayMaker.FsmEventTarget eventTarget, HutongGames.PlayMaker.FsmEvent fsmEvent)
HutongGames.PlayMaker.Fsm.Event (HutongGames.PlayMaker.FsmEvent fsmEvent)
PlayMakerFSM.OnLevelWasLoaded ()

We're using Playmaker 1.5.6f3 with Unity 3.5.7f6.

We have no ideia where this comes from? Is there any way to check from which game object/FSM this exception is coming?

All help is really, really appreciated!

Cheers.π

aktathelegend

  • Playmaker Newbie
  • *
  • Posts: 2
Re: NullReferenceException while calling OnLevelWasLoaded()
« Reply #1 on: April 24, 2013, 10:47:18 AM »
I'm getting the same error and I can't figure out why after updating to the latest version (1.5.7f2) on Unity 4.1.2. Has somebody fixed it somehow or had the same issue?

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: NullReferenceException while calling OnLevelWasLoaded()
« Reply #2 on: April 25, 2013, 02:07:21 PM »
Sorry for the delayed response. Can you email me a project that shows the bug?

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: NullReferenceException while calling OnLevelWasLoaded()
« Reply #3 on: April 25, 2013, 02:55:21 PM »
From the error log it looks like a problem with broadcasting an event while loading a level...? While I look into this, you could try workarounds, e.g., broadcasting the event after loading the level. Just a guess at this point though - will know more soon...

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: NullReferenceException while calling OnLevelWasLoaded()
« Reply #4 on: April 25, 2013, 08:51:01 PM »
I can't repro this bug ???

Really need a repro project or repro steps to figure this out!


aktathelegend

  • Playmaker Newbie
  • *
  • Posts: 2
Re: NullReferenceException while calling OnLevelWasLoaded()
« Reply #5 on: April 26, 2013, 05:23:24 PM »
Unfortunately I can't share the project, but the repro steps to me are quite simple, update Playmaker from 1.5.6 to 1.5.7 and launch the game. Any scene I try to reload (not on the first load, let's say level restart) I get basically one NullReference for each PlaymakerFSM I have in the scene.

Code: [Select]
NullReferenceException: Object reference not set to an instance of an object
HutongGames.PlayMaker.Fsm.ProcessEvent (HutongGames.PlayMaker.FsmEvent fsmEvent, HutongGames.PlayMaker.FsmEventData eventData)
HutongGames.PlayMaker.Fsm.Event (HutongGames.PlayMaker.FsmEventTarget eventTarget, HutongGames.PlayMaker.FsmEvent fsmEvent)
HutongGames.PlayMaker.Fsm.Event (HutongGames.PlayMaker.FsmEvent fsmEvent)
PlayMakerFSM.OnLevelWasLoaded ()

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: NullReferenceException while calling OnLevelWasLoaded()
« Reply #6 on: April 26, 2013, 08:29:05 PM »
The problem is it doesn't do it with just any scene. We've got plenty of test projects that load scenes, and they don't show this bug...

There's something specific in your project or your setup that I need to figure out :)

Do you get the errors with the Playmaker editor closed?
Are you using custom actions that send events?
If you start a new project that just loads a simple scene, do you get the error?
Or can you repro the error in a smaller project that you can share?

Thanks!
Alex