Any Way To combine CSharp and CPlusPlus in the One Project?

#1
Hi guys,

I used DLL files ( Windows-API ) in the Visual Basic.Net / VB6 , Now consider to that model of behavior.
I Know C#/VB.Net , both , I can use in the Application Projects.
Is possible , I use c++ and c# ( both ) in the One Project in the CryEngine 5.4 or 5.5 ?
There is a way for do/use/import both cpp/h and cs ( Source code *.cpp / *.h / *.cs ) or DLL ( *.dll files ) in the CryEngine 5.4 or 5.5 for games?

Thanks
Homescapes Mod

Re: Any Way To combine CSharp and CPlusPlus in the One Project?

#2
One way would be using the plugin system with your dll files

In your .cryproject you load C# Plugins with "type": "EPluginType::Managed"
and your C++ Plugins with "type": "EPluginType::Native"

E.g:

Code: Select all


{
"console_variables": [
{ "name": "sys_target_platforms", "value": "pc,ps4,xboxone,linux" },
{ "name": "r_displayinfo", "value": "1" }
],
"console_commands": [
{ "name": "map", "value": "example" }
],
"content": {
"assets": [ "Assets" ],
"code": [ "Code" ]
},
"info": {
"name": "Game"
},
"require": {
"engine": "engine-5.4",
"plugins": [
{ "path": "CryDefaultEntities", "type": "EPluginType::Native" },
{ "path": "CrySensorSystem", "type": "EPluginType::Native" },
{ "path": "CryPerceptionSystem", "type": "EPluginType::Native" },
{ "path": "bin/win_x64/MyCsPlugin.dll", "type": "EPluginType::Managed" },
{ "path": "bin/win_x64/MyCppPlugin.dll", "type": "EPluginType::Native" }
]
},
"type": "",
"version": 1
}
More information can be found in our Technical documentation:
http://docs.cryengine.com/display/CEPRO ... d+Plug-ins

Re: Any Way To combine CSharp and CPlusPlus in the One Project?

#3
Yes using C# and C++ for your product is very common and a good idea.

Sometimes you can use managed C++, in which case you can use your managed C++ module just like any other .NET module.

Typically you'd do everything that you can in C#. For the parts you need to do in C++ you'd typically create a C++ DLL and then call into that DLL from C#. Marshalling of parameters is done automatically for you.

Here is an example of importing a C function inside a DLL into C#:

[DllImport("user32", CharSet=CharSet.Auto, SetLastError=true)]
internal static extern int GetWindowText(IntPtr hWnd, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpString, int nMaxCount);

Re: Any Way To combine CSharp and CPlusPlus in the One Project?

#4
Hi guys,

I used DLL files ( Windows-API ) in the Visual Basic.Net / VB6 , Now consider to that model of behavior.
I Know C#/VB.Net , both , I can use in the Application Projects.
Is possible , I use c++ and c# ( both ) in the One Project in the CryEngine 5.4 or 5.5 ?
There is a way for do/use/import both cpp/h and cs ( Source code *.cpp / *.h / *.cs ) or DLL ( *.dll files ) in the CryEngine 5.4 or 5.5 for games?

Thanks
Did you find the solution?
CMD Commands are very useful.

Who is online

Users browsing this forum: No registered users and 3 guests