“Setget Godot” Code-Antworten

Godot Setget

#Both setter and getter:
var my_var setget my_var_set, my_var_get

func my_var_set(new_value):
    my_var = new_value

func my_var_get():
    return my_var # Getter must return a value.
    
    
#Only a setter
var my_var = 5 setget myvar_set


#Only a getter
var my_var = 5 setget ,myvar_get

Docs:
https://docs.godotengine.org/en/3.0/getting_started/scripting/gdscript/gdscript_basics.html?highlight=setget#setters-getters
Crazy Caracal

Setget Godot

var my_var setget my_var_set, my_var_get

func my_var_set(new_value):
    my_var = new_value

func my_var_get():
    return my_var # Getter must return a value.

#Only a setter
var my_var = 5 setget myvar_set

#Only a getter
var my_var = 5 setget ,myvar_get
Crazy Caracal

Ähnliche Antworten wie “Setget Godot”

Fragen ähnlich wie “Setget Godot”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen