godot-cpp icon indicating copy to clipboard operation
godot-cpp copied to clipboard

Can't set property for Native Script from Property Editor

Open serhiikurson opened this issue 9 years ago • 2 comments

After I've set a new value for registered property in Property Editor, I tried to read this value from GDScript.

var simpleclass = load("res://simple.gdns").new()
func _ready():
	print(simpleclass._count);

But received value setted in code (or random value if no initialisation in C++ code). This is code for registering: register_property("_count", &SimpleClass::_count, int(0)); After some research, I found that addresses for my class object are different when setting from Editor and from GDScript. For example: Value from _wrapped_setter using Editor: 90942992 Value from _wrapped_getter using GDScript: 90966512 Then I added a log to a constructor and found that my class was created 2 times. So I think this is the root of the problem. To be honestly, I don't know is it a bug or am I doing something wrong :)

serhiikurson avatar Jul 28 '17 09:07 serhiikurson

Maybe there's a bug in the property handling code. I'll check when I'm back home (in about 20 hours)

karroffel avatar Jul 28 '17 19:07 karroffel

I'm closing this if that is ok. I've used this consistently over the past year so pretty sure this is fixed by now. Please re-open if I turn out to be wrong :)

BastiaanOlij avatar Nov 22 '18 11:11 BastiaanOlij