UI Buttons not showing on play

I’m not sure if this is correct but when I enter play mode a unit is selected by default but the UI buttons do not display until I click on the unit/change unit.

Is this just how it is supposed to be working at this stage? It is hard to tell if you are having the same outcome or not.

I tried to be fancy and put the clear buttons in a function and call it on start which resulted in no buttons showing.

Now if I run it will just show the prefabs placed on the scene like so:

image

Then if I click on another unit and change back:
image

For some reason the UI isn’t updating when the game starts.

I have the SetSelectedUnit function being called on Start()
image

The event is being invoked
image

And the UnitActionSystemUI is registering to the event

It should be running, in fact it does run once the game is loaded and a unit is changed, just not on load.

This fix to this was to make the UnitActionSystemUI load before the UnitActionSystem in the project settings should anyone else have this issue.

Did you forget to call CreateUnitActionButtons(); on the UnitActionSystemUI.Start() ?

You should be calling that on Start() AND also subscribe to the event to call it whenever the selected Unit changes.
So the intended behaviour is indeed for the UnitActionSystem to run it’s own Start and set the selected Unit before the UnitActionSystemUI is listening to the event, so the UI script should not be receiving that first event, it should update on Start and after that listen to the event.

1 Like

I did miss that, I actually found it in a later video I noticed you were calling 3 functions and I only had one.

Adding that in and removing the UnitActionSystemUI from the execution order sorted that issue. :+1:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms