Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GDNative/C++] _init method of C++ class alters the owner variables in the editor #19703

Closed
lethiandev opened this issue Jun 21, 2018 · 2 comments

Comments

@lethiandev
Copy link
Contributor

Godot version:
3.0.3.stable.official.e649ec7
No-Mono

OS/device including version:
Windows 10 x64

Issue description:
I'm using gdnative like a generic gdscript in my game, but to my surprise, gdnative works differently than gdscript. The native script changes the values of the owned node by just reopening the scene tab in the editor. I'm not sure if it's an intended workflow of the gdnative.

For now, I have to feed the code by conditional test if the game isn't open in the editor:

#define SKIP_ON_EDITOR_HINT \
	if (Engine::is_editor_hint()) { return; }

void TestLabel::_init() {
	SKIP_ON_EDITOR_HINT;
	// (...)
}

IMO for the sake of gdscript, native script instantiation in the editor should be reserved for the tool classes only.

Out of curiosity, I checked how mono scripts work, and they work as I expected. The mono constructors are called only in the running game and not in the editor.

Steps to reproduce:

  • Attach a gdns to a label node
  • Reopen the scene tab with the label
  • The label have an altered text now

Minimal reproduction project:
gdnative-_init-method-call.zip

Please notice the label change in the GDNativeLabel node at the editor startup.

@karroffel
Copy link
Contributor

I'll have a look soon!

@akien-mga
Copy link
Member

Fixed by #27320.

@akien-mga akien-mga added this to the 3.2 milestone Apr 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants