{"id":93303,"date":"2019-05-10T12:16:47","date_gmt":"2019-05-10T12:16:47","guid":{"rendered":"http:\/\/gamefromscratch.com\/post.aspx?id=b82e9cd8-81bc-4ec2-99cb-8d1bac02fb45"},"modified":"2019-05-10T12:16:47","modified_gmt":"2019-05-10T12:16:47","slug":"using-c-with-unreal-engine","status":"publish","type":"post","link":"https:\/\/sickgaming.net\/blog\/2019\/05\/10\/using-c-with-unreal-engine\/","title":{"rendered":"Using C# With Unreal Engine"},"content":{"rendered":"<p>While Unreal Engine doesn\u2019t provide C# support out of the box, it does provide an exceptional plugin system, so it was only a matter of time until C# plugins arrived.&nbsp; Today we are looking at the open source <a href=\"https:\/\/github.com\/pixeltris\/USharp\">USharp extension<\/a>, which is based on the <a href=\"https:\/\/mono-ue.github.io\/\">MonoUE plugin<\/a> project.&nbsp; Using this plugin, UE4 gains C# functionality with the following features:<\/p>\n<blockquote>\n<ul>\n<li>Write C# using UObject exposed types (AActor, AGameMode, UActorComponent, etc). Define new UObject types and inherit existing ones. Exposed C# types can then be used in (or extended by) Blueprint. <\/li>\n<li>Access to <a href=\"https:\/\/www.unrealengine.com\/en-US\/blog\/unreal-property-system-reflection\">Unreal&#8217;s reflection system<\/a> (UClass, UFunction, UProperty, etc). <\/li>\n<li>Hot-reload <\/li>\n<li>Dynamically switch between .NET Framework, .NET Core and Mono for an improved debugging \/ runtime experience without having to reopen the editor <\/li>\n<li>Supports Windows, Mac and Linux <\/li>\n<\/ul>\n<\/blockquote>\n<p>There are however some downsides:<\/p>\n<blockquote>\n<ul>\n<li>This project depends on a lot of PInvoked functions which could potentially behave differently on different C++ compilers. <strong>This project may not work on some target platforms.<\/strong><\/li>\n<li>Like mono-ue this project depends on lots of generated code and IL weaving. It probably isn&#8217;t the best for performance and there is a huge amount of generated code everywhere. <\/li>\n<li>The weaved IL currently seems to break edit-and-continue debugging (issue with cecil?) <\/li>\n<li>There is currently too much marshaling on structs \/ collections (list, map, set). Marshaling needs to be redesigned to avoid copies of entire collections \/ structs on trivial calls between C# \/ native code. Additionally marshaling of delegates needs to be redesigned (various issues such as being referenced as a copy of the delegate). <\/li>\n<\/ul>\n<\/blockquote>\n<p>If you are interested in checking out USharp, you can find the installation instructions <a href=\"https:\/\/github.com\/pixeltris\/USharp\/wiki\/Plugin-Setup\">here<\/a>.&nbsp; One potential problem to be aware of, the project creator doesn\u2019t seem to have attached a license to the code repository!&nbsp; While this code is not production ready, if you intend to use it in any capacity, I would make sure the license is suitable.&nbsp; See the results of the plugin in action in the video below.<\/p>\n<p align=\"center\">[youtube https:\/\/www.youtube.com\/watch?v=sc4Odx_gbVE&#038;w=853&#038;h=480]<\/p>\n<p class=\"under\"> <span class=\"categories\"><a href=\"https:\/\/www.gamefromscratch.com\/category\/GameDev-News.aspx\">GameDev News<\/a><\/span> <span class=\"tags\"><a href=\"https:\/\/www.gamefromscratch.com\/?tag=\/Unreal\" rel=\"tag\">Unreal<\/a> <a href=\"https:\/\/www.gamefromscratch.com\/?tag=\/C%23\" rel=\"tag\">C#<\/a><\/span> <\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>While Unreal Engine doesn\u2019t provide C# support out of the box, it does provide an exceptional plugin system, so it was only a matter of time until C# plugins arrived.&nbsp; Today we are looking at the open source USharp extension, which is based on the MonoUE plugin project.&nbsp; Using this plugin, UE4 gains C# functionality [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[71],"tags":[72],"class_list":["post-93303","post","type-post","status-publish","format-standard","hentry","category-game-development","tag-gamedev-news"],"_links":{"self":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/93303","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/comments?post=93303"}],"version-history":[{"count":0,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/93303\/revisions"}],"wp:attachment":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/media?parent=93303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/categories?post=93303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/tags?post=93303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}