playMaker

Author Topic: How to fix a GUI update problem?  (Read 2355 times)

Thore

  • Sr. Member
  • ****
  • Posts: 480
How to fix a GUI update problem?
« on: September 10, 2017, 11:14:02 AM »
Hello,

I have a holder Game Object, and as a child, a GUI text Game Object. The whole thing sits in the canvas, and generally works just fine. An FSM on the holder is constantly (loop, not every frame) checking some condition, and when the condition is met, either activates, or (via another route) deactivate the GUI text child. It's thus very simple. The loop either goes one route, and has it active, or the other route, and keeps it inactive. This also works correctly.

This object is a prefab and a few of these populate the scene, and they all work just fine. Except one, or two, occasionally, that are not visible (as if inactive) despite that they are truly are active, and are supposed to be visible.

What happens: The Canvas does not show it, or update correctly. I tried the "U GUI Canvas Force Update Canvases" action to no avail. Also, when I move the object a bit by hand during runtime, it suddenly correctly displays the actual state.

I could do something hacky like move the thing by a few pixels and see if this forces the update, but that cannot be a good solution. Any ideas?

drown

  • Junior Playmaker
  • **
  • Posts: 58
Re: How to fix a GUI update problem?
« Reply #1 on: September 10, 2017, 11:58:18 AM »
Not to sure if I got it correctly, but might it be the case that the condition you are looking for is met exactly when your checking system is switching states ?

That would explain why it isnt activating even when you force the canvas to update, it simply was never activated.

Maybe you could use an external manager that listens for a global event that is sent when the condition is met and then activates the GUI object rather than having everything in that one "checking" FSM. Correct me if I totally missed you point.

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: How to fix a GUI update problem?
« Reply #2 on: September 10, 2017, 01:35:48 PM »
Here's a schematic version of this, where you can see the basic setup.

The de/activation are in the Show and Hide states. The Update one is basically empty, but I put there the force GUI update action, though it does nothing.

The logic itself works fine. Also the objects are activated and deactivated properly, according to inspector. It is just not always reflected properly in the scene.

Thanks for the reply. :)




« Last Edit: September 10, 2017, 01:38:28 PM by Thore »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: How to fix a GUI update problem?
« Reply #3 on: September 11, 2017, 03:55:16 AM »
Hi,
Can you make a video showing the issue and the fsms/states/actions?

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: How to fix a GUI update problem?
« Reply #4 on: September 11, 2017, 10:43:51 AM »
Hi,
Can you make a video showing the issue and the fsms/states/actions?

Not possible unfortunately, though there is not much to see. The logic itself works fine. I know this, because the inspector shows everything as expected. They're active when they should, and inactive when called for. But the "Game" view is wonky. As written above, the moment I move the object holder, using the scene view/transform scrubbing, it will suddenly display correctly. So it must be something with the GUI update, canvas/drawing, that does not refresh properly.

It's an annoying problem, but not a show stopper for this prototype, so if there is no hunch or idea what I could be trying, I'll have to live with it and build it differently next time. :)





djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: How to fix a GUI update problem?
« Reply #5 on: September 11, 2017, 12:55:01 PM »
Hi, you can pm a link if you don't want others to see your project.
or you can send a bug report inside unity (goto playmaker/tools/Submit Bug Report)

there can be many reasons it is happening so the more info you can give the bigger the chance to solve :)