UnrealCS - Unity alike C# Plugin for Unreal Engine

Noticed that the request of C# plugin for Unreal Engine still pops ups now and then, but not many one awares that there’s already one MIT licensed C# plugin call UnrealCS been released by xiongfang recently.

Here’s the github repository: GitHub - xiongfang/UnrealCS

Personally I don’t use C#, but I do believe text based scripting solution is still valid and useful, and hopefully this post will bring more awareness to this promisinig project. And thanks xiongfang!

Did a simple rotatinig cube test.

No matter how efficient and good a third party C# plugin might be, the people that are requesting C# will only be happy when Epic implements their own, even if it ends up been 1000 times worse.

Weird looks like this plugin is released to the UE4 marketplace in China but not here in the US. From Github,

Cool, but Xamarin already have C# for Unreal… So I’m not sure why this exists.

“Have” is too strong a word. They got something for 4.4. They have promised something better for 4.13.

Until Xamarin got a complete, easy to use and continuously updated solution, I wouldn’t dismiss other alternatives.

Nate could you explain how you got it setup? Using Launcher 4.15, I downloaded the UnrealCS from github and copied into the plugin directory under UE_4.15\Engine\Plugins after modifying the uplugin to 4.15 and it didn’t work. It threw error “Pluing ‘UnrealCS’ failed to load because module ‘MonoHelper’ could not be found. Please ensure…”.

Did you use 4.14? Did you compile from engine from source?

The only scripting system allowed to be “paid for” is SkookumScript (they charge for additional services), Epic made a statement in the Eula that all scripting languages binding to UE4 MUST be free;
If wasn’t that the case, by now we’d have plenty of professional grade scripting systems on Marketplace for everyone’s particular tastes :confused:

I built it against 4.15.1 github version. Should not be much difference for launcer version. I’ll try make a build against launcer version later.

I tried against launcher 4.14.3 and 4.15 and got the same error in either case that it could not find the monohelper. I read from you comment you both had built UE from source and you built this plugin from source. It’s not possible to build the plugin from source without the UE github code since it fails to build the required unreal engine. I’ll try building the unreal engine from source and link that to the SLN file and see if building that will allow this work.

I downloaded the current head from git (4.15 commit 76085d1) and built. That code worked, I copied the folder unreal CS into the plugins directory and it throws the same error about missing the monodeveloper plugin when I try to launch UE from VS. I’ll try rebuilding his plugin but it requires the UnrealEngine.Dll which doesn’t seem to be a thing for some reason. I wonder if I have to add his SLN into the full UE SLN. Nate please if you could do a video showing how you set this up it would be wonderful, I’m about 3 hours (1.5 hours of UE building) in trying to get this to work already.

If you include the 3 csproj files copy, maindomain, and unreal engine it will build and create a new plugin folder. However this still fails for the same reason. It seems to want to find UE4-MonoHelper.lib but I can’t seem to find any references to that file anywhere even on the internet.

Edit again: Apparently I was wrong and I was not building his UnrealEngine.dll, it has references to unreal specfic things like FEventReply and FKey and cannot build. I added to the main SLN but haven’t references any of the unreal libs yet. I’ll keep hacking at this, I’ve been waiting excitedly for years for Unreal CS.

I see from his forum you must copy the plugins code into the plugins directory and then rebuild UE from code. I’m attempting now. I’ve registered and and will try to get the precompiled off of his forum once I can reply.

I copied the unrealCS into the plugins directory and rebuild unreal engine. I get the 16 errors, like “Excepted Dochelper.h to be first header included.” where the line before it is #include “MonoPluginPrivatePCH.h”. I see now that the Monoplugins are supposed to be built the the UnrealBuild tool not by visual studio. Still no luck building the plugin.

It appears the issue is with MonoHelperPrivatePCH.h inside there the file is pretty simple:


// Copyright xg_55,All Rights Reserved.Support E-mail: xg_55@126.com
// For details, see LICENSE.txt
#pragma once
#include “CoreUObject.h”

DECLARE_LOG_CATEGORY_EXTERN(LogMonoHelper, Log, All);

#if WITH_EDITOR
#define BOOL_PROPERTY_PRIVATE_MEMBER_OFFSET 136
#else
#define BOOL_PROPERTY_PRIVATE_MEMBER_OFFSET 128
#endif

UProperty* FindScriptPropertyHelper(UStruct* Class, FName PropertyName);

I tried copying CoreUObject.h and PCH.CoreUObject.h into the directory for the DocHelper.h but that still fails in the same way.

After registering on the unrealcs forum and waiting 30 minutes I was able to download the compiled version. Once I did that I copied it into the plugins folder and Launch 4.14.3 launches without error. I see the plugin enabled but don’t know how to get the game.cs you edit. I see it in his source code. Nate if you could show more steps it would be very helpful.

I see from your video you have a game.sln with mymonocomponent and exportedassembilies, did you make that sln, and those 2 cs files? If so could you share them, I don’t see anyway to trigger UnrealCS that I want a CS project to get a baseline.

Can’t find it on the Marketplace…

It is not in the US Marketplace yet. You can compile from source but I did not find that to work, apparently Nate did. If you register on his forum, wait 30 minutes then post you can get a zip file that works to have the plugin enabled, however I don’t have the option to make a new C# project.

This is the site you have to go to get the compiled version: http://www.unrealcs.com/read.php?tid=1 (it is in Chinese, google translate in chrome works to help)

d89cee977c00812869a8c85ec42774f09c7d46c5.jpeg

@Beep2Bleep, have you got the “UnrealCS” section show up on your File menu?

Wow thank you I’m an idiot, yes it was right there. Thank you so much for the picture.
Open Project created the SLN it doesn’t open it but I can navigate to the sln and open it. I’ll attempt to replicate your spinning cube shortly.

When I click open project it launches VS 2015 but then fails to open the file. It throws an error
unrealcsfailtoload.jpg

Additionally I can make additions or changes to the sln and it will not reflect in the unreal project. I do see his testclass and it exists in the Unreal Editor. I think now the only missing step I have is after a rebuild of the SLN it’s not populating into unreal, was there any steps you took (not shown) after a build before you could use it in the editor?

I found my mistake, I had followed the steps in your video except I had NOT marked my class public. This means that my class could not be seen by the unreal editor. This makes all the sense in the world I feel silly for fighting it. Well glad to see I can get a rotating cube, I’ll attempt package and use shortly (that was the catch with Mono-UE back in the 4.3 days).

problem I had with unrealcs.png

I’m having issues running a shipping build. I can get it to run as a Development Windows No Editor On The Fly Launch from the project Launcher only. Of course this kind of build can only run on computers with UE4 installed so it’s not really viable. If I choose the launch button or package for shipping it crashes immediately. I found the following in the output log.

LogPlayLevel: MyProject: LogInit:Display: RandInit(1465887135) SRandInit(1465887135).LogModuleManager:Warning: ModuleManager: Module ‘XMPP’ not found - its StaticallyLinkedModuleInitializers function is null.
OCULUS: Info: [HMDState] Requested to SetForegroundWindow(380712ll)
LogPlayLevel: MyProject:
LogPlayLevel: MyProject: LogModuleManager:Warning: ModuleManager: Module ‘XMPP’ not found - its StaticallyLinkedModuleInitializers function is null.LogBlueprintUserMessages:Warning: DEBUG: LocalNotification DefaultPlatformService NOT FOUND
LogPlayLevel: MyProject:
LogPlayLevel: MyProject: [2017.02.22-12.04.40:955] 0]LogBlueprintUserMessages:Warning: DEBUG: LocalNotification DefaultPlatformService NOT FOUNDLogMono:Error: Could not find assembly mscorlib.dll.
LogPlayLevel: MyProject:
LogPlayLevel: MyProject: [2017.02.22-12.04.41:160] 0]LogMono:Error: Could not find assembly mscorlib.dll.LogMono:Warning: The assembly mscorlib.dll was not found or could not be loaded.
LogPlayLevel: MyProject:
LogPlayLevel: MyProject:
LogPlayLevel: MyProject: [2017.02.22-12.04.41:160] 0]LogMono:Warning: The assembly mscorlib.dll was not found or could not be loaded.
LogPlayLevel: MyProject: LogMono:Warning: It should have been installed in the `C:\Users\stick\Documents\Unreal Projects\MyProject 4.14\Saved\StagedBuilds\WindowsNoEditor\Engine\Binaries\ThirdParty\EMono\bin\lib\mono\2.1\mscorlib.dll’ directory.

If I copy an mscorlib.dll in to that directory I get an access violation but it’s possible I’m using the wrong mscorlib.dll of course.

If you launch as do not cook it will fail with the mscorlib error, but if you launch with On the Fly data build it will work. I think it’s possible what is happening is C# are getting converted to blueprints and don’t need the mscorlib. I don’t believe these are getting converted to native C++ since that fails when you attempt a package with that option.

After research I found the issue is the following. When not cooking completely the MyProject5\Content\Scripts is not being completely regenerated. Specifically the EngineAssemblies, framework, and GameAssemblies folders and content. This is the content generated but UnrealCS. If you copy the content from a good build (made with Launcher Down Arrow -> Project Launch, Advanced Options set Data Build to “On The Fly” into that folder your build will work.

Yes! That does work, with a shipping packaged build.

If anyone needs a short version of the steps to get a working packaged build.

  1. Make a “good build” with Launcher Down Arrow -> Project Launch, Advanced Options set Data Build to “On The Fly”
  2. Confirm it works then rename the folder ex. C:\Users\stick\Documents\Unreal Projects\MyProject5\Saved\StagedBuilds\WindowsNoEditor -> C:\Users\stick\Documents\Unreal Projects\MyProject5\Saved\StagedBuilds\WindowsNoEditor = Works
  3. Go to Package Project -> Packaging Settings and turn off use PAK file
  4. Set packaging type to shipping
  5. Package for Win64/32
  6. Attempt to run the project note that it fails to run
  7. Copy your unreal directory EX. C:\Users\stick\Documents\Unreal Projects\MyProject5\Saved\StagedBuilds\WindowsNoEditor\MyProject5\Content\Scripts to the same folder under your packaged location.
  8. Run your shipped executable and marvel at Unreal C# working on 4.14.3 (at least).

@Beep2Bleep, good job! And I applause your determination.

Just an idea, you could try adding those 3 folders to the "Additional Non-Asset Directories to Package " in the project package setting. That way you don’t have to copy them manually.

Oh I didn’t know that was an option last time I looked hard into Unreal was 4.3 when Mono for Unreal looked like a possiblity. I hope to make a full end to end youtube tutorial video sometime shortly.

Could anyone share a compiled build here?