Search code examples
godot

Invalid set index 'rect_min_size' (on base: 'Button') with value of type 'Vector2'. GODOT


GODOT version v4.2.1.stable.official [b09f793f5]

my code:

# Dieses Skript verwaltet den Hauptbereich mit dem 16x16 Raster.
extends Control

func _ready():
    # Erstelle ein 16x16 Raster aus quadratischen Kacheln.
    for x in range(16):
        for y in range(16):
            var kachel = Button.new() # Verwendung von Buttons als Platzhalter für Kacheln
            kachel.rect_min_size = Vector2(40, 40) # Korrekte Zuweisung der Größe als Vector2
            kachel.rect_position = Vector2(x * 40, y * 40) # Positionierung der Kachel
            add_child(kachel)

somehow I cannot get that running. Anyone able to help? Documentation says that rect_min_size is of type Vector2, so I don't see the thing which I don't see. I am obviously missing something here...

HELP!!!

already tried stupid stuff like doing things like: var a=Vector2(40,40) kachel.rect_min_size = a same error ;-)


Solution

  • The property rect_min_size existed in Godot 3 but not in Godot 4.

    You might be able to set custom_minimum_size in Godot 4. However, make sure that you do not want to set size instead.

    If you are using the online documentation, you can see the version of Godot for which you are reading the documentation in the bottom left, and also in the URL.