Table of Contents

C#: Development with Unreal

Creating C# Classes

To explain how to achieve this in Unreal, follow this potential scenario:

  1. Let's say we have a C# class that 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;
    		    }
    		}
    }
    
    
  2. 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

  3. 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

Note

We recommend you store your C# objects in a variable in the blueprint. This can be done by right-clicking on the output and hitting Promote to Variable.


Other Mono Functionality

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