Converting EditorProperty _update_property() to C-Sharp

Godot Version

4.4.1.stable

Question

How do you get the new EditorProperty value in C#?

In an EditorProprty, it gets a new_value via:

func _update_property():
	var new_value = get_edited_object()[get_edited_property()]

in C#, I have:

public override void _UpdateProperty()
{
	GodotObject obj = GetEditedObject();
	StringName propName = GetEditedProperty();
	var new_value = obj[propName]; // does not work because GodotObject has no indexing

Looking through the obj.GetPropertyList, I can find the dictionary with the propName, but that dictionary doesn’t hold a new value – just various metadata on the property.

How do I find the new value in C#?

Try using Object.get() instead.

1 Like

You are correct!

public override void _UpdateProperty()
{
	int newValue = GetEditedObject().Get(GetEditedProperty()).As<int>();