playMaker

Author Topic: Restart Level Action loading level twice?  (Read 8929 times)

Mayhem

  • Full Member
  • ***
  • Posts: 171
    • View Profile
Restart Level Action loading level twice?
« on: August 30, 2013, 03:13:00 PM »
Hey there,

so I had an issue with another plugin after using the Restart Level Action. The developer of the plugin looked into it and told me this:

Quote
With the SoundManagerPro debug logs on (check 'Show Debug Info'), I noticed that PlayMakers call to Restart Level is loading the level twice immediately (which is making SoundManagerPro essentially run it's functions in Awake on the second load). You might want to contact them about that, because I'm sure that's not intended behavior.

Let me know if that's not what's happening to you. With the Debug logs on, it'll show something like this:
(2.489183) In Level Loaded: Sandbox
If that shows up twice exactly the same(the number in parenthesis is the time it is called), then something is wrong with their restart level.

Is there something wrong with that action?

Edit:

Same stuff with the Level-Load-Action...
« Last Edit: August 30, 2013, 03:15:13 PM by Mayhem »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3639
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Restart Level Action loading level twice?
« Reply #1 on: August 31, 2013, 09:51:44 AM »
Can you submit a bug report: PlayMaker > Tools > Submit Bug Report

When you get the link to the bug, please attach a small repro project if possible.

I'm travelling back from Unite, but I can look at this first thing next week...

Mayhem

  • Full Member
  • ***
  • Posts: 171
    • View Profile
Re: Restart Level Action loading level twice?
« Reply #2 on: August 31, 2013, 11:54:09 AM »
Well I can't actually attach a sample scene, but I can explain it:

- when you have an empty scene with only SoundManagerPro and PlayMaker and use either the "Restart Level" or any of the "Load Level"-Actions then you'll get an Error in SoundManagerPro:

Quote
IndexOutOfRangeException: Array index is out of range.
SoundManager.CheckWhosPlaying () (at Assets/SoundManagerPro/Scripts/Managers/SoundManager_Internal.cs:131)
SoundManager.PlayClip (UnityEngine.AudioClip clip2play) (at Assets/SoundManagerPro/Scripts/Managers/SoundManager_Internal.cs:34
SoundManager+<PlaySoundConnection>c__Iterator12.Mo veNext () (at Assets/SoundManagerPro/Scripts/Managers/SoundManager_Internal.cs:74
UnityEngine.MonoBehaviour:StartCoroutine(String, Object)
SoundManager:HandleLevel(Int32) (at Assets/SoundManagerPro/Scripts/Managers/SoundManager_Internal.cs:160)
SoundManager:OnLevelWasLoaded(Int32) (at Assets/SoundManagerPro/Scripts/Managers/SoundManager.cs:24)

I asked the dev of the SoundManagerPro Plugin and as already posted in the Unity-Topic, he told me this:

Quote
With the SoundManagerPro debug logs on (check 'Show Debug Info'), I noticed that PlayMakers call to Restart Level is loading the level twice immediately (which is making SoundManagerPro essentially run it's functions in Awake on the second load). You might want to contact them about that, because I'm sure that's not intended behavior.

Let me know if that's not what's happening to you. With the Debug logs on, it'll show something like this:
(2.489183) In Level Loaded: Sandbox
If that shows up twice exactly the same(the number in parenthesis is the time it is called), then something is wrong with their restart level.

And it showed up twice at my side, so it has to be a bug, I guess. So the Actions are loading the level twice and I guess this is not intended.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3639
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Restart Level Action loading level twice?
« Reply #3 on: August 31, 2013, 01:24:32 PM »
When using Restart Level it's very easy to create a loop without meaning to since all GameObjects in the scene are reset when the level is loaded. So if Restart Level is in the start state it will get called again when the level is re-loaded.

This may be what you're seeing... Where is your Restart Level action? When are you calling it?

EDIT: For example, try Restarting the level on some user input (pressing a key). Does it still call SoundManagerPro twice?
« Last Edit: August 31, 2013, 01:31:37 PM by Alex Chouls »

Mayhem

  • Full Member
  • ***
  • Posts: 171
    • View Profile
Re: Restart Level Action loading level twice?
« Reply #4 on: August 31, 2013, 01:32:57 PM »
I have one certain Restart-Button which has one FSM.

The first state is empty and has only one transition called "OnClick" (UIEventsToPlayMaker-Script for NGUI Buttons!), when OnClick is triggered it goes to the second state, which only has that Restart-Level-Action. So it's definitely not in the Start-State.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2493
  • Mender of the past
    • View Profile
    • Cleverous
Re: Restart Level Action loading level twice?
« Reply #5 on: August 31, 2013, 01:54:29 PM »
Try using a keyboard key to trigger the restart level state and see if it persists.

Mayhem

  • Full Member
  • ***
  • Posts: 171
    • View Profile
Re: Restart Level Action loading level twice?
« Reply #6 on: August 31, 2013, 02:02:02 PM »
Tried it, it still persists :/

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3639
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Restart Level Action loading level twice?
« Reply #7 on: August 31, 2013, 02:08:45 PM »
I just did a quick test with a MonoBehavior logging on Awake and Start and it's definitely not loading the level twice. There's something else going on. I'll need to look at SoundManagerPro to debug it...

Is SoundManagerPro using a custom action? Does it happen with the Playmaker editor closed?

Mayhem

  • Full Member
  • ***
  • Posts: 171
    • View Profile
Re: Restart Level Action loading level twice?
« Reply #8 on: August 31, 2013, 02:12:39 PM »
No. I don't use any SoundManagerPro-related actions at all. There is only a SoundManagerObject with the SoundManager Script attached, and there you can select the AudioClips which shall play. No PlayMaker involved there.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15377
  • Official Playmaker Support
    • View Profile
Re: Restart Level Action loading level twice?
« Reply #9 on: September 10, 2013, 02:55:33 AM »
Hi,

 Using the log from soundManagerPro, can you trace from where exactly the second level loading comes from?

Usually, to debug this kind of issues, I edit the custom action in question to put logs, so that I know exactly when and who fired the offensive second loading. Else, it's difficult to track since the debug flow of playmaker loose what happens prior the loading.

 If you have problem editing custom actions, let me know, I can help you.

 Bye,

 Jean

Mayhem

  • Full Member
  • ***
  • Posts: 171
    • View Profile
Re: Restart Level Action loading level twice?
« Reply #10 on: September 10, 2013, 10:47:27 AM »
Where and what exactly should I DebugLog?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15377
  • Official Playmaker Support
    • View Profile
Re: Restart Level Action loading level twice?
« Reply #11 on: September 11, 2013, 12:11:10 AM »
Hi,

 ok:

-- In the action browser, locate the "LoadLevelNum" action.
-- Right click on that action and select "Edit Script"
-- line 41, add the following: Debug.Log("Loading Level: "+levelIndex.Value);

Now when you run, you will see in the Unity console when this action is called.

 Does that help? if you are using a different action, like LoadLevel, then the debugs are already implemented.


Bye,

 Jean

Mayhem

  • Full Member
  • ***
  • Posts: 171
    • View Profile
Re: Restart Level Action loading level twice?
« Reply #12 on: September 19, 2013, 03:30:01 AM »
Sorry for the late answer, but I wasn't at home the last couple of days.
I edited the Debug.Log in the Script and got this Info:

Quote
Loaded Level: 0
UnityEngine.Debug:Log(Object)
HutongGames.PlayMaker.Actions.LoadLevelNum:OnEnter() (at Assets/PlayMaker/Actions/LoadLevelNum.cs:42)
HutongGames.PlayMaker.FsmState:ActivateActions(Int32)
HutongGames.PlayMaker.FsmState:OnEnter()
HutongGames.PlayMaker.Fsm:EnterState(FsmState)
HutongGames.PlayMaker.Fsm:SwitchState(FsmState)
HutongGames.PlayMaker.Fsm:UpdateStateChanges()
HutongGames.PlayMaker.Fsm:DoTransition(FsmTransition, Boolean)
HutongGames.PlayMaker.Fsm:ProcessEvent(FsmEvent, FsmEventData)
HutongGames.PlayMaker.Fsm:Event(FsmEventTarget, FsmEvent)
HutongGames.PlayMaker.Fsm:Event(FsmEvent)
HutongGames.PlayMaker.Fsm:Event(String)
PlayMakerFSM:SendEvent(String)
UIEventsToPlaymakerFSM:OnClick() (at Assets/1/SCRIPTS/CustomScripts/UIEventsToPlaymakerFSM.cs:40)
UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
UICamera:Notify(GameObject, String, Object) (at Assets/NGUI/Scripts/UI/UICamera.cs:678)
UICamera:ProcessTouch(Boolean, Boolean) (at Assets/NGUI/Scripts/UI/UICamera.cs:1195)
UICamera:ProcessMouse() (at Assets/NGUI/Scripts/UI/UICamera.cs:946)
UICamera:Update() (at Assets/NGUI/Scripts/UI/UICamera.cs:801)

Just for the record, I don't know why and how, but the error which I mentioned above does not happen anymore? Did you guys changed something of the Restart Level Actions (LoadLevel, LoadLevelNum, Restart Level etc.) in the last PM-Updates?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15377
  • Official Playmaker Support
    • View Profile
Re: Restart Level Action loading level twice?
« Reply #13 on: September 20, 2013, 12:06:11 AM »
Hi,

 so here, it's loading only once. Are you running other frameworks, other than playmaker? or maybe you have scripts dealing with level loading as well?

bye,

 Jean

Mayhem

  • Full Member
  • ***
  • Posts: 171
    • View Profile
Re: Restart Level Action loading level twice?
« Reply #14 on: September 20, 2013, 01:56:00 AM »
Other Frameworks? You mean like uScript? No, I just use PlayMaker.
And no, 100% sure scripts aren't loading any level.