Unreal Engine 4 .NET Core integration

栏目: IT技术 · 发布时间: 5年前

内容简介:UnrealCLR is a plugin which natively integrates .NET Core host into the Unreal Engine with the Common Language Runtime for direct execution of the managed code through user-driven blueprint pipelines to build a game logic using the full power of .NET facil

Unreal Engine 4 .NET Core integration

UnrealCLR is a plugin which natively integrates .NET Core host into the Unreal Engine with the Common Language Runtime for direct execution of the managed code through user-driven blueprint pipelines to build a game logic using the full power of .NET facilities with engine API. The project is aimed at stability, performance, and maintainability.

API reference | Roadmap | Legend | Support | Contact

Features:

  • Host loading, integration, and management during the lifetime of the engine
  • Dynamic loading, unloading, isolation, and dependency resolving of user assemblies at runtime
  • On-the-fly access and execution of the managed functionality through blueprints
  • Runtime exceptions handling and tracing
  • Continuously evolving framework for access to the engine API from the managed code written in idiomatic C#
  • High-performance interoperability through generated IL code and utilization of blittable data types
  • Support of .NET facilities including hardware-accelerated math with transparent re-mapping to vector types of the engine
  • Support of .NET tools for debugging and profiling such as JetBrains product line, dnSpy debugger, and others
  • Full independence from the compilation pipeline of assemblies with support of NuGet packages, analyzers, and generators
  • Automatic project packaging for standalone distribution
  • Carefully handcrafted source code for best maintainability and performance
  • Extensive unit testing to ensure the robustness and consistency
  • Distributed as a plugin and doesn't require rebuilding the engine
  • Documented source code

The plugin is available for Windows, Linux, and macOS (x64).

Building

Prerequisites

Auto

Compilation

Create a new or use an existing Unreal Engine C++ or blueprints project. Clone the repository or download a desirable version from the releases section. Navigate to Install folder, and run dotnet run command. Follow the installation instructions. Open the project after the installation process is complete.

Upgrading

To upgrade the plugin, re-run the installation process. Recompile custom code with an updated framework.

Manual

Compilation

Plugin

Create a new or use an existing Unreal Engine C++ or blueprints project. Clone the repository or download a desirable version from the releases section. Copy the content of the Source/Native folder to %Project%/Plugins/UnrealCLR directory. Compile the managed runtime from Source/Managed/Runtime folder by running the following command: dotnet publish --configuration Release --framework netcoreapp3.1 --output "%Project%/Plugins/UnrealCLR/Managed" . Restart Unreal Engine, open the project, and build the plugin.

Tests

To quickly start testing, open a project with the plugin in Unreal Engine, copy all folders from the Content of the repository to %Project%/Content directory, and wait until they loaded in the Content Browser. Compile the managed assemblies from Source/Managed/Tests folder by running the following commands:

dotnet publish "../Framework" --configuration Release --framework netcoreapp3.1
dotnet publish --configuration Release --framework netcoreapp3.1 --output "%Project%/Managed/Tests"

Upgrading

To upgrade, delete the plugin folder from a project, and repeat all steps from the compilation section. Recompile custom code with an updated framework.

Running

Plugin

The plugin is automatically loaded at startup. To make sure that it's initialized open the console window from Window -> Developer Tools -> Output Log , find UnrealCLR logs using the search input.

Tests

Open the scene with tests in the editor and enter the play mode. To switch a test, navigate to Blueprints -> Open Level Blueprint , select the Test Systems enumeration, and change default value on the right panel.

Overview

Design and architecture

UnrealCLR is designed to be flexible and extensible. The plugin is transparently managing core functionality of the runtime, binding and caching the engine API for managed environment. The programmer has full control over execution flow through blueprint pipelines that allow to dynamically weave native events of the engine and its objects with managed logic. There's no hidden states or obscured order of execution behind the lifecycle of scripts.

Assemblies management

At runtime, UnrealCLR loading managed assemblies into a cached isolated context. It allows dynamically replace assemblies after unloading them from memory, therefore the programmer can work with code without restarting the editor for continuous development. The compilation pipeline is entirely up to a developer, it can be organized in any desirable way without any limitations and with full support of NuGet packages.

Engine application program interface

The plugin and framework are evolving all the time to utilize as much power of the Unreal Engine as possible. It's crucial to have a feature-rich API. The system is created with high-performance in mind but without trading safety. The vast majority of code is written and verified by hand to prevent any unexpected behaviors at runtime and to ensure stability.

Powerful tooling

Use your favorite IDE and .NET Core tools that can be attached to the process of the engine just as to a regular .NET application for profiling and debugging. It's very convenient and works out of the box without any external effort. Analyze performance, monitor CPU usage and memory consumption, debug execution, take full control over the code. Explore new possibilities and extend your toolset in no time.

Essentials

Exceptions

The runtime redirects all unhandled exceptions to log files and on-screen messages of the engine, however, it's highly recommended to use try/catch blocks to override redirections with custom handlers. It's necessary to have an attached debugger to properly trace exceptions in the editor or standalone.

Memory management

Unreal Engine, as well as .NET runtime, utilizes a garbage collector for memory management. The framework is designed with consistency in mind to prevent crashes and validate memory transparently for a programmer, no matter how objects were created and freed: with C++, C#, or blueprints.

Hot reload

The plugin is independent of the compilation routine of user assemblies. It's loading assemblies from %Project%/Managed folder in accordance with user-driven blueprint pipelines and resolving dependencies at runtime after entering/leaving the play mode. The framework of the plugin with the engine API is automatically recognized and loaded as a dependency.

Ecosystem compatibility

The framework replicates the classes hierarchy of the engine with full interoperability support. Any external C++ code, blueprints, and plugins are compatible and extensible with UnrealCLR by design through the engine API.

Acknowledgments

Thanks to @natemcmaster for a great .NET library that simplifies dynamic loading of assemblies.

Special thanks to @Doraku for an amazing documentation generator and rapid improvement of it.


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

高扩展性网站的50条原则

高扩展性网站的50条原则

[美] Martin L. Abbott、[美]Michael T. Fisher / 张欣、杨海玲 / 人民邮电出版社 / 2012-6-3 / 35.00元

《高扩展性网站的50条原则》给出了设计高扩展网站的50条原则,如不要过度设计、设计时就考虑扩展性、把方案简化3倍以上、减少DNS查找、尽可能减少对象等,每个原则都与不同的主题绑定在一起。大部分原则是面向技术的,只有少量原则解决的是与关键习惯和方法有关的问题,当然,每个原则都对构建可扩展的产品至关重要。 主要内容包括: 通过克隆、复制、分离功能和拆分数据集提高网站扩展性; 采用横向......一起来看看 《高扩展性网站的50条原则》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具