k
kaiyou

Question about cross-language scripting

Hello, I'm from Japan. There may be some inaccuracies in the description, please be understanding


I am using C# as the main scripting language in my project and everything has been working normally so far. However, when I tried to connect to a signal in a third-party plugin written in GDScript dynamically from my C# script, I couldn't find a way to do it even after trying multiple methods and searching for information. Is this an unsupported approach? Also, connecting to the signal manually from the editor works fine.


If anyone here has had a similar experience or has any experience with this, please share it with me. Thank you very much.

  • Nathan Lovato replied

    In C#, as far as I know, you need to get the node to connect to their signals. We don't have much experience with the interoperability with GDScript, but this doesn't work?

    Getting the node by path:

    PluginNodeType pluginNode = GetNode<PluginNodeType>("Path/To/Desired/Node");

    Then accessing the signal as usual:

    pluginNode.custom_signal

    If you've already tried this and this doesn't work, I would recommend searching in the engine's issue tracker or getting in touch with people who use C# with Godot.

    1 love
  • k
    kaiyou replied

    Thank you very much for your reply!

    After several attempts, I finally found a solution to this problem. I shouldn't have been fixated on obtaining the gd script in C# code and converting it to GDscript type. Instead, I should have obtained the corresponding node and connected the signal through the node's reference. By doing so, I successfully connected to the signal in my C# code.

    1 love
  • a
    andrewjhaugen replied

    I'm glad to hear you got it resolved! Thanks for sharing your solution with us as well!

    1 love