jacksondunstan/UnityNativeScripting

How to automatic convert C++ types to Managed types?

sekkit opened this issue · 2 comments

Successfully embedded Python to UnityNativeScripting,
but when executing code below:
import UnityEngine
UnityEngine.Debug.Log('hello')

TypeError: Log(): incompatible function arguments. The following argument types are supported:
1. (self: System::Object) -> None

Invoked with: 'helloworld'

At:
(3):

UnityEngine.Debug:Log(Object)
NativeScript.Bindings:UnityEngineDebugMethodLogSystemObject(Int32) (at Assets/NativeScript/Bindings.cs:1372)

PS: I wanna do:
UnityEngine::Debug::Log("helloworld")
instead of
System::String msg = System::String("hellworld");
UnityEngine::Debug::Log(msg)

All basic types shall be automatically casted to Managed types.

I can't speak for the Python part, but I can talk about the C++ side. Passing C++ string literals to functions that take an Object isn't currently possible because a string literal is const and, since C# functions have no concept of const, the parameter is not const in C++. So the compiler rightly complains that a const value is being passed as a non-const parameter.