playMaker

Author Topic: Global references disappear when returning to scene  (Read 3843 times)

TeamCherry

  • Playmaker Newbie
  • *
  • Posts: 6
Global references disappear when returning to scene
« on: November 22, 2016, 02:06:52 AM »
After recently upgrading from Unity 5.3 to 5.4 and moving from PlayMaker 1.7.8 to 1.8.3 I've encountered an issue with globals.

Starting play mode in a scene, let's call it "scene A" will begin with a number of singleton prefabs setting global references to themselves on Start through PM. They all are set up in the same way, the use variations of the same singleton behaviour and they all "globalize" themselves the same way. These GameObjects are intended to persist throughout scene change and so only need to set that reference once.

Since upgrading PM, references to these persistent globals are lost if the player returns to the scene they started on.

e.g. Testing in editor, hit play on Scene A. Move hero to Scene B, no issue. Move hero back to Scene A and some global references will be lost.

Moving to any other scene as far as I can tell causes no loss of references but if at any point the hero visits Scene A again, these globals refs will vanish and I'm not sure why. After that point the refs cannot be re-linked unless the game is restarted. The strange part is I can't establish why only some objects show the problem but I can say it's always the same set of objects that experience the issue.

Can anyone suggest what has changed from Unity/PlayMaker that could cause this? I'm wondering if there is something to do with multi-scene editing, I'm still trying to establish what the affected objects have in common that could be the cause. It only impacts global variables (these are of type GameObject).

Cheers

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Global references disappear when returning to scene
« Reply #1 on: November 28, 2016, 03:54:58 AM »
Hi,

Do you have any errors in the Unity console?

What I suggest is the following, hopefully you do have backups right?

 In 5.3 first, upgrade to 1.8 and see if it works, then upgrade Unity to 5.4. Can you try that?

Also, just to make sure, these gameobjects do persists between scene loading right?
because once a gameobject is destroyed the reference is also lost, and so even if the next scene recreate the gameobject, the global variable won' know which one it is. Just triple check that aspect too, it could be that simple (hopefully)

for gameobjects to persists during level loading, use "dontdestroyOnLoad" action to flag a GameObject to not be destroyed when loading a new scene.

 Bye,

 Jean

TeamCherry

  • Playmaker Newbie
  • *
  • Posts: 6
Re: Global references disappear when returning to scene
« Reply #2 on: December 02, 2016, 01:19:56 AM »
Hi Jean,

Yep we've got backups and version control.

So I've rolled a copy back to the pre-upgrade state and installed PlayMaker 1.8.0 beta (I think, it was suggested by the Welcome Screen) and then stepped up to 1.8.3 as our prefabs have been updated using that version.

So far most things work but I'm having 3 errors relating to actions, I get these when I switch scenes but not on the first scene load:

Code: [Select]
Error Loading Action: Wait : HutongGames.PlayMaker.Actions.Wait : time
System.ArgumentOutOfRangeException: ArgRange_Array
Parameter name: index

Error Loading Action: Deactivate : HutongGames.PlayMaker.Actions.ActivateGameObject : activate
System.ArgumentOutOfRangeException: ArgRange_Array
Parameter name: count

Error Loading Action: Deactivate : HutongGames.PlayMaker.Actions.ActivateGameObject : recursive
System.ArgumentOutOfRangeException: ArgRange_Array
Parameter name: index


I'm having a hard time tracking down the source of these errors, updating these actions makes no change. On a side note I would love it if PlayMaker specified the name of the GameObjects these errors originated from.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Global references disappear when returning to scene
« Reply #3 on: December 02, 2016, 01:26:22 AM »
Hi,

 yes, it's not optimal for sure. Hopefully this will be improved over time.

 ok, this error is indicating that it's getting mixed up between dataversion 1 and 2, very likely.

you should directly install the latest version of playmaker straight from 1.7.8 without going via a beta version. Can you try that? thanks, we'll see then what you get.

Bye,

 Jean


TeamCherry

  • Playmaker Newbie
  • *
  • Posts: 6
Re: Global references disappear when returning to scene
« Reply #4 on: December 04, 2016, 06:15:39 PM »
Hi Jean,

I've gone through the rollback process, this time from 1.7.8 to 1.8.3. There were a couple of items to fix in terms of old actions but they work now.

However I see the same 3 errors as above. Are these actions in the core dlls? Can I update just those parts of PM and keep my current setup of actions?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Global references disappear when returning to scene
« Reply #5 on: December 05, 2016, 08:57:32 AM »
Hi,

 it's going to be tricky,

the actions are individual c#, I would definitly try to delete them from your project completly and then reimport them to shake up PlayMaker.

Can you try that?

you know It's odd cause I have the same problem with my introspection system, and I think it's an issue with dataversion 1 and data version 2.

 Can you check on that fsm where it has this issue if the fsm data version is 1 or 2?



can you also file a bug viy the PlayMaker menu?, I'll cross reference this with my own reports.


 Bye,

 Jean

TeamCherry

  • Playmaker Newbie
  • *
  • Posts: 6
Re: Global references disappear when returning to scene
« Reply #6 on: December 06, 2016, 08:38:42 PM »
Hi Jean,

Thanks for your help so far, I've got that bug report submitted. We have a workaround for now by adding the Level Loaded global event to these objects to ensure they are still set to global.

We are testing to see if we can forge ahead with Unity 5.4 and PlayMaker 1.8.3, which means the errors I was seeing won't be an issue.

For the most part we have everything working but there's one major change was saw moving to PlayMaker 1.8 from 1.7 was that our build size increased dramatically. When I investigated, I saw our scenes had increased in size by more than double. I checked that this wasn't Unity upgrade related so I made builds in both 5.3 and 5.4 using both PM 1.7 and 1.8.

Here are the results (scene size in build, not total build size):

Unity 5.4 with PlayMaker 1.8: 5515 MB
Unity 5.3 with PlayMaker 1.8: 5508 MB
Unity 5.3 with PlayMaker 1.7: 2027 MB

Now these scenes contain many prefabs that make extensive use of FSMs, we have no idea where the extra size would come from though. Do you have any ideas?

Cheers

TeamCherry

  • Playmaker Newbie
  • *
  • Posts: 6
Re: Global references disappear when returning to scene
« Reply #7 on: December 11, 2016, 06:55:08 PM »
I thought I would add to this another possible reason for the scene size increase, when the PlayMaker FSM based prefabs in a scene receive the "FSM Updated, please save scene/project" message, what is updated in those GameObjects?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Global references disappear when returning to scene
« Reply #8 on: December 12, 2016, 02:14:34 AM »
Hi,

 yes, odd findings indeed!

Data and internals serialization is updated. Maybe the old data is kept. You can check this with the dataversion at the bottom of the Fsm Tab in the PlayMaker Editor.


Bye,

 Jean