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

Problems with binds[] array when emitting signal (Mono) #16311

Closed
xfactor2000 opened this issue Feb 2, 2018 · 2 comments
Closed

Problems with binds[] array when emitting signal (Mono) #16311

xfactor2000 opened this issue Feb 2, 2018 · 2 comments

Comments

@xfactor2000
Copy link

Godot version: 3.0 stable

OS/device including version:
Manjaro Linux 64 bit (rolling release,so no version is available)

Issue description:
Facing multiple issues when trying to pass parameters from pressed signal (probably other signals as well) using object[] binds

Steps to reproduce:

Please see attached project for full description, to sum it up:
when doing
b1.Connect("pressed",this,"_on_Button_pressed",new object[]{1,2});
I get compiler error Method Not Found (when button is clicked)

when doing
b2.Connect("pressed",this,"_on_Button_pressed",new object[]{1});
No error is raised, but binds[] array in the function is empty

The only workaround is to wrap the array in another array:
b3.Connect("pressed",this,"_on_Button_pressed",new object[]{new object[]{1,2}});

Seems like a bug to me

Minimal reproduction project:
Binds bug.zip

@KellyThomas
Copy link
Contributor

@xfactor2000
I am finding success with this approach:

    public override void _Ready()
    {
        b1 = GetNode("Button1") as Button;
        b1.Connect("pressed", this, "_on_Button_pressed", new object[]{1, 2});
    }

    private void _on_Button_pressed(int p1, int p2)
    {
        GD.Print($"Params: {p1}, {p2}");
        // prints: Params: 1, 2
    }

@xfactor2000
Copy link
Author

@KellyThomas you are right. I think more docs should be added on the matter, right now they're scarce.

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

3 participants