C#: Development with Unreal
💬 How do I get my C# code in Unreal?
Have a look at the Operator’s Guide on C#: Compiling for Unreal
before continuing. Essentially, you just need to make sure when you build your C# library it outputs the binary files into the correct location in NominalForUnreal
plugin.
Note
If you are developing a
PhysicalComponent
, have a look atEditor: PhysicalComponent Breakdown
guide
💬 How do I create my C# class in Unreal?
To explain how to achieve this in Unreal, lets follow this potential scenario:
- Lets say we have a C# class which contains some variables and functions we want to use in Unreal:
namespace MyNamespace
{
public class MyClass
{
// This is a C# field
public double MyDoubleField = 5.0;
// This is a C# property
public double MyDoubleProperty
{
get => MyDoubleField
set => MyDoubleField = value * -1.0
}
// This is a C# function
public void LetsChangeMyDoubleValue()
{
MyDoubleValue += MyDoubleValue * 2.0;
}
}
}
- Now in Unreal, you can use the
Get MonoType
node andCreate Mono Object
node to create your C# object:- Make sure C# class, variables and functions are made public
- The name of your C# type is
<<NAMESPACE_NAMES>>.<<CLASS_NAME>>
- The last step is to create a
weak
orstrong
reference to the C# object- Weak references are used when you want to point to a C# object that may exist or not - use
Create Mono Object Ref
node - String references are used when you want the C# object to exist for the entire duration of the level - use
Create Mono Object Pinned Ref
node
- Weak references are used when you want to point to a C# object that may exist or not - use
💬 What other functionality exists with Mono
Currently, Nominal supports functionality around a C# Instance\Object since users may want to create custom classes that may not inherit from the NominalSystems
namespace. Below is a list of the blueprint nodes you can use with C# objects: