-
|
How to set/modify non-exported values, such as position or scale of an object in console? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
unfortunately you can not directly modify a non-object's property by a single expression, but you can achieve this by a wrapper function like this: func set_anything(variable, property:String, val):
if typeof(variable) == TYPE_VECTOR2:
if property == "x":
variable.x = val
elif property == "y":
variable.y = val
return variablenow, you can change a vector2's property by # a is a sprite2d
current.a.set("position", current.set_anything(current.a.position, "x", 100))this is indeed inconvenient, need more work on command parser in the future work. |
Beta Was this translation helpful? Give feedback.
-
|
I made a change to improve this. I replaced the checks for d.usage == PROPERTY_USAGE_SCRIPT_VARIABLE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_STORAGEwith (d.usage == PROPERTY_USAGE_SCRIPT_VARIABLE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_STORAGE) or (d.usage == PROPERTY_USAGE_SCRIPT_VARIABLE | PROPERTY_USAGE_NO_INSTANCE_STATE)in exporter_2.gd and gdexprenv.gd. Then each property that I want to edit in game, but not in editor, I add the following export to: @export_custom(PROPERTY_HINT_NONE, "", PROPERTY_USAGE_SCRIPT_VARIABLE | PROPERTY_USAGE_NO_INSTANCE_STATE)Works like a charm. |
Beta Was this translation helpful? Give feedback.
unfortunately you can not directly modify a non-object's property by a single expression, but you can achieve this by a wrapper function like this:
now, you can change a vector2's property by
this is indeed inconvenient, need more work on command parser in the future work.