ZerxZ / GDBridge

Package to simplify C# -> GDScript interoperability

Home Page:https://www.nuget.org/packages/GDBridge/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Test

GDBridge

⚠Not feature complete

Some thing can change but not that much.

Simple package to simplify C# -> GDScript interoperability.
It comes in two part the bridge code and the source generator.
The generator will parse all the GDScript in the project and generate a C# GDBridge class for each of them.
It aims to reduce or remove the need to use string and untyped way of communicating with GDScript from C#.

Feature

  • Call GDScript from C#.
  • Use your C# class in the generated code(Even the bridge themselve).
  • Respect the _private method and field.
  • Configurable.
  • GodotObject support.
  • Only generate class if there is matching partial bridge class in your project.
  • Signal support. And more to come.

How to use(See Sample)

Make sure to instal both GDBridge and GDBridge.Generator.
Only script with class_name will be bridged.
Variable and function starting with _ are not expose in the bridge by default.

Add this to your .csproj:

  <ItemGroup>
    <AdditionalFiles Include="**/*.gd"/>
    <!-- Add this if you want to exclude GDScript in addons -->
    <!--<AdditionalFiles Remove="addons\**"/>-->
  </ItemGroup>
using GdBridge;

var myGDScript = new GdScriptBridgeFactory(this).ResolveNode<ArenaBridge>(arena);

myGDScript.on_configure(42);

The bridge class is partial, so you can extend it if needed.
The bridge class is in the global namespace.
You can extend it like this:

partial class ArenaBridge
{
    public void DoSomethingElse(int deckId) => on_configure(deckId);
}

How to configure(Optional)

Create the GDBridgeConfiguration.json in the root directory and add this to it:

{
    "UsePascalCase": true
}

The schema is here: Configuration.cs

Feel free to ask for feature or question.

What do you want?

Pull Request are welcome.

About

Package to simplify C# -> GDScript interoperability

https://www.nuget.org/packages/GDBridge/

License:The Unlicense


Languages

Language:C# 71.3%Language:GDScript 27.9%Language:GAP 0.8%