UnrealSharp is a plug-in developed for UnrealEngine 5. Through this plug-in, you can use pure C# to develop UnrealEngine 5 projects.
- Support C#
Hot Reloading
in non-playing state - Supports
.NET 6.0
~.NET 8.0
[default is.NET 8.0
], supportsC#12
- Supports creating new
Unreal classes
,Unreal structures
,Unreal enumerations
, etc. in C# - Supports creating new
Unreal properties
,Unreal functions
, andUnreal multicast delegates
for C# class. - Supports C# classes to
inherit Unreal C++ classes
, which means you can implement your own UObject, UActorComponent, and AActor subclasses in C# - Supports
overriding C++
Event functions in C# - Support access to
all
C# classes, structures, enumerations, methods, delegates, etc. from Unreal Blueprints - Supports Unreal Blueprint classes
inheriting C# classes
andoverriding all C# UFunctions
in blueprints - Support
debugging
C# code throughVisual Studio
orRider
, and support simultaneous debugging of C++ and C# - When the C# code you write does not comply with Unreal Sharp's specifications, you will get a compilation error during the
compilation phase
. At the same time, UnrealSharp will tell you the error type of theerror code
, the codefile
and theline number
. You can jump directly with a double-click. This No different than a normal C# compilation error. - Supports automatically generating corresponding C# binding code for Unreal C++ or Unreal Blueprint [optional]. As long as Unreal's classes, structures, enumerations, functions, etc. can be accessed in blueprints, almost all of them can be accessed in C#.
- Most C++ APIs are automatically generated as versions based on C# Function Pointers to improve calling speed.
- This interactive function framework based on C# Function Pointers is public. You can register a new C++ API with the framework if necessary.
- Automatically align Unreal and C# memory management and object lifetimes so you almost never have to handle anything yourself.
- The style of C# binding code remains the same as Unreal C++, and there is almost no difference between calling these C++ interfaces and in C++.
AOT friendly
, support for AOT has been considered from the initial design.- Pure plug-in design, you don’t need to modify any engine source code
- In addition to the three special projects reserved by the framework, you can add any number of C# projects, and it also supports implementing corresponding Unreal types in these projects.
Chip | Windows | Linux | macOS | IOS | Android |
---|---|---|---|---|---|
x64 | ✔ | ? | ✔ | − | ✖ |
Arm64 | ✖ | ✖ | ✔ | ? | ? |
- ✔ Supported and verified
- ✖ Not supported and no follow-up plans
- ? It is theoretically supported or planned to be supported, but it has not yet been verified and may require further testing and modification.
- − target platform is not exists.
32-bit architecture is not supported on all platforms
Please note that the type restrictions here only apply to those involved in generating Unreal classes and structure properties, UFunction parameters and return values, etc. For ordinary C# code, there are no restrictions on types.
Type | UPROPERTY Of USTRUCT | UPROPERTY of UCLASS | UFUNCTION PARAMS | UFUNCTION Return Type | FastAccess |
---|---|---|---|---|---|
bool | ✔ | ✔ | ✔ | ✔ | ✔ |
char | ✖ | ✖ | ✖ | ✖ | ✖ |
sbyte | ✖ | ✖ | ✖ | ✖ | ✖ |
byte | ✔ | ✔ | ✔ | ✔ | ✔ |
short | ✖ | ✖ | ✖ | ✖ | ✖ |
ushort | ✖ | ✖ | ✖ | ✖ | ✖ |
int | ✔ | ✔ | ✔ | ✔ | ✔ |
uint | ✖ | ✖ | ✖ | ✖ | ✖ |
Int64 | ✔ | ✔ | ✔ | ✔ | ✔ |
UInt64 | ✖ | ✖ | ✖ | ✖ | ✖ |
float | ✔ | ✔ | ✔ | ✔ | ✔ |
double | ✔ | ✔ | ✔ | ✔ | ✔ |
string | ✔ | ✔ | ✔ | ✔ | partial |
FName | ✔ | ✔ | ✔ | ✔ | ✔ |
FText | ✔ | ✔ | ✔ | ✔ | ✖ |
Enums | ✔ | ✔ | ✔ | ✔ | ✔ |
UObject | ✔ | ✔ | ✔ | ✔ | ✔ |
UClass | ✖ | ✖ | ✖ | ✖ | ✖ |
Structures | ✔ | ✔ | ✔ | ✔ | conditional |
TSubClassOf<T> |
✔ | ✔ | ✔ | ✔ | ✔ |
TSoftObjectPtr<T> |
✖ | ✔ | ✔ | ✖ | ✖ |
TSoftClassPtr<T> |
✖ | ✔ | ✔ | ✖ | ✖ |
TArray<T> |
✔ | ✔ | ✔ | ✔ | ✖ |
TSet<T> |
✔ | ✔ | ✔ | ✔ | ✖ |
TMap<TKey,TValue> |
✔ | ✔ | ✔ | ✔ | ✖ |
TDelegate<Signature> |
✖ | ✖ | ✖ | ✖ | ✖ |
TMulticastDelegate<Signature> |
✖ | ✔ | ✔ | ✖ | ✖ |
Other C# types | ✖ | ✖ | ✖ | ✖ | ✖ |
- ✔ : Fully Support
- ✖ : Not Support, Not supported means not allowed in C# Use this type in this form.
- conditional : Conditional support, For example, among structures, only structures that meet the conditions can use fast access, that is, the memory size, layout, attribute type and offset of the C++ structure and the C# structure are exactly the same, and the attribute types also support fast access.
- partial : Partially supported,Strings support fast parameter passing, but when the passing method is by reference, fast access is not supported.
When there is a parameter type in the function that does not support fast access or the return value does not support fast access, the function call in normal mode will be used, which is slower than fast access.
To use this library, you need these few steps, you can click on the link to get the details, or directly check the video tutorial list on youtube:
- Install .NET 8.0 SDK for your development platform
- Install Visual Studio or Rider [Visual Studio Code has not been tested yet]
- Clone or download this project. Copy the Plugins directory and GameScripts directory to your Unreal C++ project (pure Blueprint projects are not supported)
- Prepare UnrealSharp ThirdParty
- Add a dependency on UnrealSharp in Build.cs of your game project
- Build your Unreal Project and then start UnrealEditor
- Export Unreal C++ type database or Unreal Blueprint type database from: Tools>UnrealSharp>Export Database or use console command :
- UnrealSharp.ExportDatabase
- UnrealSharp.ExportUnrealCppDatabase
- UnrealSharp.ExportBlueprintDatabase
- open GameScripts/UnrealSharp.sln, Select your development platform's Configuration, upgrade nuget package UnrealSharp.Toolkit, It is best to keep the version number consistent with the version number of UnrealSharp. Different version numbers may not be compatible; compile this solution.
C# binding code and C++ interaction APIs will be automatically generated during the compilation process [if you enable this function]. - If you enable C++ interactive code generation, you need to recompile your C++ code and start Unreal Editor again. The deployment is complete.
- The next thing you have to do is learn how to add C# code in C# according to the specifications to implement Unreal Class, Unreal Struct, Unreal Enums, etc.
- C# projects specifications
- C# Programming Specifications
- How to add a new Unreal type in C#?
- How to add a UFunction to UClass?
- About Unreal Collections In C#
- How to debug UnrealSharp's C# codes?
- How to reset UnrealSharp?
- How to work without UnrealSharp.Toolkit?
There are some known issues here that may affect you; these issues may or may not be resolved in subsequent plans, so be sure to pay attention.
Known Issues
This is a newly born small project, there is still a lot to do before it can grow into a useful project, but one person's energy is really limited. If you are interested in this, take a look and try to choose a topic to complete. Anyone is welcome to submit a PullRequest, you just need to make sure it makes sense and runs correctly.
To-do List
You can directly visit the issues page of this project to submit bug reports or suggestions.
UnrealSharp is licensed under the MIT license.