ONE Way for 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
C++ Programmer
https://www.youtube.com/AhmadKarami

Re: ONE Way for combine CSharp and CPlusPlus in the One Project ?

#2
You can combine managed and native plugins in the same project. The only part that you need to watch out for is that generating a solution can get weird.

The easiest way to combine C++ and C# in one project is to use the C# assets in the Asset Browser of a C++ project. This will create a new managed plugin that will be automatically handled by the Sandbox.

The other option is to make a new C# or C++ project from the plugin template in the launcher. Next you want to move the .dll files of the plugin to your game project and specify the location of the .dll file in the cryproject file like this:

Code: Select all

[...]
"require": {
"engine": "engine-5.5",
"plugins": [
{ "type": "EPluginType::Native", "path": "CryDefaultEntities" },
{ "type": "EPluginType::Native", "path": "CrySensorSystem" },
{ "type": "EPluginType::Native", "path": "CryPerceptionSystem" },
// This is the original game plugin. This a native plugin made with C++.
{ "type": "EPluginType::Native", "path": "bin/win_x64/Game.dll" },
{
"type": "EPluginType::Native",
"path": "CryGamePlatform",
"platforms": [ "PS4" ]
},
// This is the managed plugin made with C# which is from a different project.
// Make sure the value of "path" is set to the correct file, and that the .dll file is copied to that location.
{ "type": "EPluginType::Managed", "path": "bin/Plugin.dll" }
]
},
[...]
In case that you copy the above example, don't forget to remove the comments because they will invalidate the JSON.

Keep in mind that by default it's not possible to easily call native functions from managed code, and the other way around. At the moment you would have to set this up yourself if you require this functionality.

Re: ONE Way for combine CSharp and CPlusPlus in the One Project ?

#5
It looks like you're missing the path to you C# game.dll in the plugins list. You also don't need to add CRYENGINE.CSharp.dll to your plugins. That dll is the Sandbox plugin that will be automatically added if you have C# files in your assets.

So you game plugins will need to be set like this:

Code: Select all

"plugins": [
{ Other plugins },
{ "type": "EPluginType::Native", "path": "bin/win_x64/Game.dll" }, // <- This is the C++ plugin
{ "type": "EPluginType::Managed", "path": "bin/Game.dll" } // <- This is the C# plugin
]

Who is online

Users browsing this forum: No registered users and 1 guest