playMaker

Author Topic: Playmaker v1.7.3.f1 Streamed Webplayer Crash [SOLVED]  (Read 5238 times)

floky

  • Playmaker Newbie
  • *
  • Posts: 7
Playmaker v1.7.3.f1 Streamed Webplayer Crash [SOLVED]
« on: June 09, 2014, 06:46:41 PM »
Hi,

I'm another happy Playmaker client but I've hit a nasty wall for a project that has a tight deadline. (don't they all :D)

I need to make a streamed webplayer build in Unity that has defined some global variables in our state machines using Playmaker v1.7.3.f1.

I have a simple scene that will wait for the rest of the webplayer to be streamed/downloaded before going to the next scene. (it contains a FSM for checking some things)

The problem is that the webplayer crashes on the first scene load (the loader scene mentioned above) because it seems a playmaker singleton class is trying to access the Resources folder to load PlayMakerGlobals.asset.

As the unity docs specify, if you build a streamed webplayer and you specify the FirstStreamedLevel to something else than level 0, then no one must attempt to access Resources.Load until that specified FirstStreamedLevel is finished downloading.

Playmaker tries to load the PlayMakerGlobals.asset from the Resources folder because it's being used in the initial loading scene.
Is there a way around this to make Playmaker play nice with a streamed webplayer? An alternative way of passing the global variables asset at run-time through a reference maybe?

Thank you for all your support!

P.S. I can't update to the latest playmaker version. Well...at least not anytime soon. :)


« Last Edit: June 14, 2014, 09:52:19 AM by Alex Chouls »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: Playmaker v1.7.3.f1 Streamed Webplayer Crash
« Reply #1 on: June 09, 2014, 10:38:55 PM »
Hmmm, I had no idea about that limitation...

Unfortunately Resources.Load will get called the first time Playmaker tries to look at the PlayMakerGlobals asset - which is when a PlayMakerFSM loads. I can't think of a way to delay this, but I'll do some digging... can you point me to the docs you referenced?

You might have to remove the PlayMakerFSMs from Level 0 and replace that FSM with a script...

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Playmaker v1.7.3.f1 Streamed Webplayer Crash
« Reply #2 on: June 10, 2014, 04:54:33 AM »
Hi,

 Then, can you not change the order of your scenes so that 0 is an empty scene. I do that quite a lot actually, calling it a "stub", it woul dhold the splash screen copy for a seamless fade out of similar. In your case it could be to overcome this issue.

If you need help writing this script, let me know, I'll help you.

bye,

 Jean

floky

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Playmaker v1.7.3.f1 Streamed Webplayer Crash
« Reply #3 on: June 10, 2014, 12:36:41 PM »
Hi,

 Then, can you not change the order of your scenes so that 0 is an empty scene. I do that quite a lot actually, calling it a "stub", it woul dhold the splash screen copy for a seamless fade out of similar. In your case it could be to overcome this issue.

If you need help writing this script, let me know, I'll help you.

bye,

 Jean

It's not that easy of a fix.
The problem is that my LoaderScene which does some animations and stuff is using Playmaker to control the animations and waits for the next scene (the big one that contains the Resources contents) to download. So this LoaderScene doesn't have the Resources contents downloaded yet and if Playmaker tries to load something from it, it will crash.

If I place another empty scene in front of all this and set the FirstStreamedLevel to this loader scene I would just have another loader scene that must not use Playmaker in it at all until the next scene (which will contain the Resources data) finishes downloading.

Like Alex suggested, the only safe thing I can do is replace Playmaker with normal scripts that don't access Resources.Load(...), but it is a pity. :(
It would be awesome to have in a future version a way to manually init PlaymakerGlobals.asset ahead of time somehow. (drag'n drop in a scene maybe?)



floky

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Playmaker v1.7.3.f1 Streamed Webplayer Crash
« Reply #4 on: June 10, 2014, 12:38:52 PM »
Hmmm, I had no idea about that limitation...

Unfortunately Resources.Load will get called the first time Playmaker tries to look at the PlayMakerGlobals asset - which is when a PlayMakerFSM loads. I can't think of a way to delay this, but I'll do some digging... can you point me to the docs you referenced?

You might have to remove the PlayMakerFSMs from Level 0 and replace that FSM with a script...

Here's the link to the docs I was mentioning:
http://docs.unity3d.com/Manual/WebPlayerStreaming.html

"...You can set which level will include all assets that can be loaded through Resources.Load in the Edit->Project Settings->Player using the First Streamed Level With Resources property. Obviously you want to move Resources.Load assets as late as possible into the game or not use the feature at all."

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: Playmaker v1.7.3.f1 Streamed Webplayer Crash
« Reply #5 on: June 10, 2014, 05:01:50 PM »
Does the FSM in Level 0 access global variables? You could try not using globals until a later scene, and set that scene as the First Streamed Level With Resources.

floky

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Playmaker v1.7.3.f1 Streamed Webplayer Crash
« Reply #6 on: June 11, 2014, 02:55:53 AM »
Does the FSM in Level 0 access global variables? You could try not using globals until a later scene, and set that scene as the First Streamed Level With Resources.

That's the weird thing I was thinking about last night. The FSM in that Loader scene is only using some PlayAnimation actions and not accessing any global variables. But I see them trying to be initialized as soon as that scene loads.
Bare in mind that I'm using Playmaker v1.7.3.f1. Maybe in this version the globals are being initialized as soon as any FSM executes?

Soooo I tried some crazy stunt. I made a simple DontDestroyOnLoad MonoBehavior script where I defined a public PlayMakerGlobals variable, placed it in another empty scene before all other scenes and dragged and dropped the PlayMakerGlobals.asset on that script. This would load the asset into memory in the first streamed scene.
It seems that the globals are initialized and Playmaker doesn't attempt to load them from the Resources folder anymore in the loader scene and I can use the FSM correctly. I hope the globals aren't going to get messed up because of this workaround.
« Last Edit: June 11, 2014, 03:07:44 AM by floky »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: Playmaker v1.7.3.f1 Streamed Webplayer Crash
« Reply #7 on: June 11, 2014, 11:15:21 AM »
This sounds like a good workaround - very clever! It shouldn't mess up globals, but I'd keep an eye on things since it is untested on our end...

floky

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Playmaker v1.7.3.f1 Streamed Webplayer Crash [Solved]
« Reply #8 on: June 11, 2014, 08:15:26 PM »
The awesome reason this works great so far is because probably under the hood you're checking if there is an instance of the globals asset already initialized, you're not attempting to load it again through the Resources.Load(...) method. :D
Thank God! :D

Basically any ScriptableObject once it's linked to a GameObject in the scene it will be initialized and OnEnable will be called on it.

So far this thread can be considered solved! ;)
« Last Edit: June 12, 2014, 04:00:05 AM by floky »