Reputation: 103
I am working on a basic 2D C++ Game engine but i want to be able to use C# to make games with it like unity does but I'm not sure how to do it. I've seen people saying about CLI but not sure exactly how that works. I want to be able to access functions on the engine in C# and be able to have the engine run the C# code.
Thanks for any help with this.
Upvotes: 0
Views: 124
Reputation: 67352
Right now you have two big ways of doing this:
Make your C# application generate COM objects which you can consume from C++. Performance is a bit iffy, but doable and very simple.
Use reverse PInvoke, where you export functions from your C++ application with in
function pointers that you fill in from the C# side with delegates to the functions that drive your code.
In .Net 5, there's a third way: you can directly export C# functions from your assemblies to be consumed in a platform-independent way, like in C++ (ie, .dll or .so exports).
Upvotes: 5