Hi dear community.
I'm trying to iterate a foreach loop using a for in like in the next example. I need to get the index to multiply the button size and spawn it in the correct spot.
for i, unit in selected_units: //i gives me an error
if not buttons.has(unit.name):
var but = button.instance()
var offset = 64
but.rect_position = Vector2(buttons.size() * i + offset , $UI/NinePatchRect.rect_size / 2)
I know i can create an var outside the loop and the incrementate but thats ugly.
I'm new in gdscript and python. Any kind of help will be appreciated.