Table of Contents

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 at Editor: 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:

  1. 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;
		    }
		}
}
  1. Now in Unreal, you can use the Get MonoType node and Create Mono Object node to create your C# object:
    1. Make sure C# class, variables and functions are made public
    2. The name of your C# type is <<NAMESPACE_NAMES>>.<<CLASS_NAME>>

Untitled

  1. The last step is to create a weak or strong reference to the C# object
    1. Weak references are used when you want to point to a C# object that may exist or not - use Create Mono Object Ref node
    2. 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

Untitled

💬 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:

Untitled