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

Signals registered from base class are not avialiabe for its sub-classes. #26

Closed
Geequlim opened this issue Jul 29, 2017 · 6 comments
Closed

Comments

@Geequlim
Copy link

Register classes like this

class BaseClass : public GodotScript<Reference> {
    GODOT_SUBCLASS(BaseClass, Reference);
public:
    static void _register_methods() {

        register_signal<BaseClass>("my_signal");

        register_property("title", &BaseClass::title, String());
    }

    String title;
};

class SubClass : public  BaseClass {
    GODOT_SUBCLASS(SubClass, BaseClass);
};

/** NativeScript Initialize **/
NATIVESCRIPT_INIT() {
    register_class<BaseClass>();
    register_class<SubClass>();
}

It can't work in GDScript

func _ready():
    var script = NativeScript.new()
	script.library = load("res://nativelib.tres")
	script.class_name = "SubClass"

	var inst = script.new()
	inst.connect("my_signal", self, "_callback")

func _callback():
    print("-----------")
@RameshRavone
Copy link
Contributor

This is happening because the signal's are registered to the BaseClass reference, may be we can somehow register the signals from BaseClass into SubClass when instancing.

@karroffel
Copy link
Contributor

This should work, maybe it's a bug in the module, if it's in the bindings then it should be easy to fix. Will take a look at this later

@karroffel
Copy link
Contributor

https://github.com/godotengine/godot/blob/master/modules/nativescript/nativescript.cpp#L290

I think it might be because of that, I don't search for the base classes.

@karroffel
Copy link
Contributor

@Geequlim can you update your Godot build and test if this still is a problem?

@Geequlim
Copy link
Author

Geequlim commented Jul 30, 2017 via email

@RameshRavone
Copy link
Contributor

We better close this,

BastiaanOlij added a commit to BastiaanOlij/godot-cpp that referenced this issue Sep 22, 2021
mashumafi pushed a commit to mashumafi/godot-cpp that referenced this issue Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants