GUI Limit. Assertion failed: (Capacity() - Size() > 0), function Push (SOLVED)

GO that have GUI-objects inside are causing the error

Assertion failed: (Capacity() - Size() > 0), function Push

when I spawn many (~50-60) of such GOs. This error crashes the application during start-up.

  1. Is this GUI limitation a matter of some setting?
  2. My units have healthbars which are represented as GUI box-nodes, is this an optimal/preferred way of implementing healthbars?

@sicher @britzl

1 Like

Hi Ivan! :relaxed:

I think there is a max capacity of 64 GUI scenes. (This could maybe turned into a setting in the future, if there are some good reasons.)

I’m guessing each of your units have their own GUI scene with one healthbar in each?
I would suggest instead you have one GUI scene with a healthbar box node and clone that one depending on how many units are visible on the screen maybe, then reposition these as the units/camera move, and update their size depending on the units healths.

For example, you could then let each unit send a message to the GUI when it moves with its new position and health. And likewise, when the unit is destroyed, send a message to the GUI to notify it can remove the healthbar.

Hope this helps! :slight_smile:

1 Like

I second Sven’s suggestion. One GUI scene for all health bars is the way to go. It’s not only better because you won’t hit the GUI scene limit, but it’s also better from a rendering perspective since you’ll be able to reduce the number of draw calls (each GUI scene will result in at least one draw call).

2 Likes

Thank you @sven and @britzl.
I’m changing my implementation as you suggested.

I only want to show the healthbar when the user selects a unit.

Is it more efficient to change the color to transparent when the unit is deselected or to delete and clone new healthbars every time a unit is selected/deselected?

When something is transparent, does Defold still make an effort to “draw” it, or is it ignored during rendering?

1 Like

The time it takes to clone and delete nodes is not that high and it sounds as if this isn’t something you’re going to do it every frame. Still, I would suggest that you enable/disable the nodes instead using gui.set_enabled() instead of setting alpha to zero.

2 Likes