TNativeArray

A more optimized approach to unreals arrays for doing fast copying as well as being able to share data between managed and native without marshalling costs.

[UClass]
public partial class AActorTest : ACharacter
{
    [UProperty(PropertyFlags.EditAnywhere)]
    public partial TNativeArray<int> NativeArrayTest { get; set; }

    [UProperty(PropertyFlags.EditAnywhere)]
    public partial TNativeArray<int> NativeArrayTest2 { get; set; }

    public override void BeginPlay()
    {
        base.BeginPlay();

        Span<int> test = [5, 6, 7, 8];
        NativeArrayTest.CopyFrom(test);

        Span<int> test2 = stackalloc int[NativeArrayTest.Length];
        NativeArrayTest.CopyTo(test2);

        NativeArrayTest2.CopyFrom(test2);
    }
}

You can also use NativeArray without any marshalling costs

TNativeArray can also be represented as an ReadOnlySpan inside of a UFunction

Supported Types

Currently right now NativeArray only supports numerical primitive types

Last updated