jacksondunstan / UnityNativeScripting

Unity Scripting in C++

Home Page:https://jacksondunstan.com/articles/3938

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Android] Return type within the C# import for the C++ binding function is always void

JmgrArt opened this issue · comments

I tried adding another abstract method returning bool in the AbstractBaseBallScript example class and calling the generator (after manually adding a stub override in BaseBallScript to prevent a compilation error in Unity), but the return type of the generated C# binding function is always void. This results in a compilation error when building a player for Android. Building for the Editor is working as expected.
The following change seems to fix the issue: (in the file GenerateBindings.cs, at line 8688)

// C# import for the C++ binding function
        AppendCsharpImport(
                GetTypeName(type),
                typeParams,
                funcName,
                invokeParams,
                typeof(void),
                builders.CsharpImports);

Into:

// C# import for the C++ binding function
        AppendCsharpImport(
                GetTypeName(type),
                typeParams,
                funcName,
                invokeParams,
                invokeMethod.ReturnType,
                builders.CsharpImports);

Hi @JmgrArt, thanks for pointing this out! All the MonoBehaviour "message" functions return void so this seems to have been an oversight that still worked in my testing. I've made your suggested change in commit 2180b3e. Please let me know if you find any more issues!