playMaker

Author Topic: Global variables reappearing after reopening project  (Read 1055 times)

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Global variables reappearing after reopening project
« on: March 19, 2020, 06:56:46 PM »
Hi guys.

Ok, so i did a little bit of spring cleaning of a project and i decided to ditch most of the globals and only the ones most frequently used since the globals have been nothing but trouble since i started working in Playmaker. That said, i made a globals manager that will hold all the relevant variables as local variables and everything else will just fetch stuff from it instead of using the global variable directly.

So i needed to transfer a lot of FSMs from using global variables to fetching variables from the manager and saving them locally. No sweat, i simply made local variables, named them the same and replaced the used global variables in states with local ones. Actually, almost every time those globals were actually replaced in states with locals the second i created the local variable with the same name as global variable.
Global variable disappears from the Variables tab and appears as a local.

The first problem i encountered was that the globals used count in the scene sometimes remained the same and pointed to FSM's that no longer used the global variable but local instead. Deleting the globals that were, according to used count in the scene, in use in some FSM's didn't cause any issues, those FSM's kept using local variables and everything worked fine.

However, after closing and reopening the project, those globals appeared in the list again, this time wih 0 usages. When i delete them again, save the project, close it and open it again, they appear again.

I will probably try deleting them again, exporting globals and then importing them to see if that will fix the issue, but there's clearly a problem.

If that doesn't help, i'll edit the asset file myself and hope they won't come back.

Globals suck, don't use them unlesss you have to.
Available for Playmaker work

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 772
Re: Global variables reappearing after reopening project
« Reply #1 on: March 23, 2020, 08:22:30 AM »
Globals do have their problems, yes. In fact, "scene refresh" barely does any good work. What happened to me was that I was swapping a Global with another one and was left with one instance of that Global that I could simply not remove despite the fact that it was clearly deleted on the last FSM I was updating.

Globals are not stored as an asset accessible within Unity so either you use PM tools which don't fully work, or circumvent this with a deus ex machina.
I found it easier to increment the scene saving and then restart Unity.

The best way to solve this once and for all, I think, would be to organize a march and then a sitting in front of Hutong Games and go on a hunger strike.

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Global variables reappearing after reopening project
« Reply #2 on: March 24, 2020, 09:13:13 AM »
Imma grab my pitchfork.
Available for Playmaker work