Re: How to make a C# Gameplugin that is the UI

#3
You can add a C# plugin to your project. For this you can create a new C# Blank project, and move the contents of the code-folder to the code-folder of your project.
If you're using CRYENGINE 5.3 (from the Launcher) you have to add the C# plugin to the cryplugins.csv file. If you're using one of the 5.4 preview builds you have to add the C# plugin to the Game.cryproject file in your project. In there you add a new entry in the "plugins" list. The new entry would look like this:

Code: Select all

{ "path": "bin/Game.dll", "type": "EPluginType::Managed" }
Make sure that your C++ and C# .dll files are not conflicting with each other. If they build to the same location you can adjust the output in the solution of the C# and C++ project.

Sending data between C++ and C# will be a bit harder though because at the moment there is no system in place to transfer data between the two. This doesn't mean it's impossible, but you would need to set up a way to communicate between C++ and C# yourself.

Re: How to make a C# Gameplugin that is the UI

#5
I know this is an old post but, I just found out Adobe has combined Flash, animation, and other things into Adobe Animate CC.
You can get it for $19 US a month. or the Pro version for $26/Month. You can also pay a few extra dollars for each plan to get access to a bunch of extra apps and things to assist Animate CC. Also read that you can start a Flash document in the program and still choose ActionScript 2.0 for which there are still a lot of tutorials on the internet for. For buttons, animating effects on buttons, visual effects, layer/page transitions, etc. After that, you can look at CryEngine Tutorials for using Flash UI. It may take a little time, but it looks like you can still get decent UI's up and running in flash.

Re: How to make a C# Gameplugin that is the UI

#6
You can add a C# plugin to your project. For this you can create a new C# Blank project, and move the contents of the code-folder to the code-folder of your project.
If you're using CRYENGINE 5.3 (from the Launcher) you have to add the C# plugin to the cryplugins.csv file. If you're using one of the 5.4 preview builds you have to add the C# plugin to the Game.cryproject file in your project. In there you add a new entry in the "plugins" list. The new entry would look like this:

Code: Select all

{ "path": "bin/Game.dll", "type": "EPluginType::Managed" }
Make sure that your C++ and C# .dll files are not conflicting with each other. If they build to the same location you can adjust the output in the solution of the C# and C++ project.

Sending data between C++ and C# will be a bit harder though because at the moment there is no system in place to transfer data between the two. This doesn't mean it's impossible, but you would need to set up a way to communicate between C++ and C# yourself.
Hi,
I am attempting to accomplish what you outlined above.

What I have done so far:
  • Added a managed C# plugin to my C++ project. This works.
  • Created a Visual Studio solution with a C++ and a C# subproject that is setup to generate interoperability code using SWIG. This works.
  • Linked/included the resulting libraries from SWIG generated code with my C# and C++ projects. This works.
  • Setup a simple C++ test class in the SWIG solution and attempted to use it in the C# plugin. This failed (see below).
C++

Code: Select all

#pragma once class cpp_file { public: ~cpp_file() {} int Times2(int arg); { return arg * 2; } };
C#

Code: Select all

using System; namespace CryEngine.Projects.MyProject { public class Interop : IDisposable { private cpp_file _cppf; public void Initialize() { _cppf = new cpp_file(); Log.Always("cppf: {0}", _cppf.Times2(2)); } public void Dispose() { _cppf.Dispose(); _cppf = null; } } }
Launching this in a debug session crashes the game. Here is the debug output from Visual Studio:
Image
<21:04:09> [Warning] [Lua Error] Failed to load script file scripts/main.lua
<21:04:09> [Warning] [CScriptSystem::BeginCall] Function OnInit not found(check for syntax errors or if the file wasn't loaded)
<21:04:09> [Warning] Handled managed exception with debugger attached:
System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (System.Reflection.Assembly,bool)
at System.Reflection.Assembly.GetTypes () [0x00000] in C:\j\workspace\v\repos\mono\mcs\class\corlib\System.Reflection\Assembly.cs:402
at CryEngine.Engine.ScanAssembly (System.Reflection.Assembly assembly) [0x00006] in D:\jk\gamesdk_release\Code\CryManaged\CESharp\Core\Engine.cs:121
GameLauncher.exe has triggered a breakpoint.
Do you have any idea why this might not work? I noticed Crytek use SWIG for scripting language interop (C#, Lua, Ruby, Python, etc) so I assume it is possible.

Re: How to make a C# Gameplugin that is the UI

#9
It looks like it's failing because it is trying to scan an assembly (something we do to automatically register entity components), probably because it is a SWIG assembly that Mono can't load dynamically.

We're planning on exposing a way of communicating between C++ and C# in the future which doesn't involve SWIG as it often causes quite a few problems. Internally we are already moving away from using SWIG, but it's a very slow process since it pretty much involves wrapping the whole engine's interface.

Who is online

Users browsing this forum: No registered users and 1 guest