playMaker

Author Topic: Accessing all global variables and resetting them on scene load?  (Read 6888 times)

playmakerNewb

  • Playmaker Newbie
  • *
  • Posts: 15
I currently have a few global variables that I use throughout my game.  I've found that even if I do a complete re-load of my scene, that my global variables do not reset themselves.

1.  Is this expected?  If I'm reloading a scene, then why aren't globals reset?
2.  If this is normal behavior, then how can I access all global vars to make sure that they're all reset prior to re-load?

Are there any inherit API functions that will allow me to "get all" variables, then reset them back to default values?

Thanks.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Accessing all global variables and resetting them on scene load?
« Reply #1 on: July 17, 2012, 08:04:06 AM »
hi,

 yes, they are not resetting, and I am not aware of any api to reset global variables to their default value. So the option you have is to listen to level load ( there is a system even call "LEVEL LOADED" in playmaker) change and set your various globals again

bye,

 Jean

playmakerNewb

  • Playmaker Newbie
  • *
  • Posts: 15
Re: Accessing all global variables and resetting them on scene load?
« Reply #2 on: July 17, 2012, 11:17:53 AM »
I was afraid of that.

I ended up putting some code into my own level loader that I'm using that wipes out all global bools.  For the time being, this works, but I'm hoping for a better implementation in the future, or a way to destroy all global variables associated with a scene when a new scene is loaded...

szomaza

  • Sr. Member
  • ****
  • Posts: 253
Re: Accessing all global variables and resetting them on scene load?
« Reply #3 on: June 08, 2014, 03:32:06 AM »
Old topic, but I just found the same problem still exists.
Please explain why don't global variables reset to their default value, when the application is exited and restarted.
Why do they have a default setting if you must set them to some default value every time you start the application?

Thanks in advance:
szomaza

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: Accessing all global variables and resetting them on scene load?
« Reply #4 on: June 08, 2014, 07:56:21 AM »
i agree, its a bit of a strange behavior...

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Accessing all global variables and resetting them on scene load?
« Reply #5 on: June 09, 2014, 04:30:01 AM »
Hi,

 I think we are getting confused here.

 What do you mean by "exited" and "restarted", global variables values persists as long as the application runs, if you stop the app and restarte the global variable will use the value defined in Unity.

 Are you testing on mobile? else what platform are you testing on?

Bye,

 Jean

szomaza

  • Sr. Member
  • ****
  • Posts: 253
Re: Accessing all global variables and resetting them on scene load?
« Reply #6 on: June 29, 2014, 03:25:55 AM »
I am testing in Unity on Windows.
I press play to run the application, then press play again to stop running it.  ("exit" the application)
Then to "restart" I press play again.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Accessing all global variables and resetting them on scene load?
« Reply #7 on: June 29, 2014, 12:31:04 PM »
This is probably a bug. The editor behavior changes subtly in each version of Unity sometimes breaking things that worked before. What version of Unity are you using? Try closing the Globals Window when entering/exiting play mode.

moondust.games

  • Playmaker Newbie
  • *
  • Posts: 46
Re: Accessing all global variables and resetting them on scene load?
« Reply #8 on: May 24, 2015, 09:38:02 AM »
Hi,

I'm having this problem now in Unity 5 and latest PM build.

When I stop playing in editor and restart the game the global variable values haven't been reset to their initial values.

e.g. X=0 as default
press play and during game X is changed to 5
stop game
start game again and X still equals 5 at the start.

Thanks.

moondust.games

  • Playmaker Newbie
  • *
  • Posts: 46
Re: Accessing all global variables and resetting them on scene load?
« Reply #9 on: May 24, 2015, 09:55:07 AM »
Edit - it seems sometimes they reset and sometimes (mostly) they don't and retain their in-game values after quitting the preview.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Accessing all global variables and resetting them on scene load?
« Reply #10 on: May 25, 2015, 09:57:32 AM »
Hi,

 ok, can you report this viy the bug reporting tool? Thanks

Unity menu: "PlayMaker/Tools/Sbmit bug Report"


 Bye,

 Jean