Class NativeCopyUtility
Utilities for copying native arrays.
Namespace: UnityEngine.XR.ARSubsystems
Syntax
public static class NativeCopyUtility : object
Methods
PtrToNativeArrayWithDefault<T>(T, Void*, Int32, Int32, Allocator)
Creates a NativeArray
from a pointer by first copying length
defaultT
s into the NativeArray
, and then overwriting the
data in the array with source
, assuming each element in source
is sourceElementSize
bytes.
Declaration
public static NativeArray<T> PtrToNativeArrayWithDefault<T>(T defaultT, void *source, int sourceElementSize, int length, Allocator allocator)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
T | defaultT | A default version of |
Void* | source | A pointer to a contiguous block of data of size |
Int32 | sourceElementSize | The size of one element in |
Int32 | length | The number of elements to copy. |
Allocator | allocator | The allocator to use when creating the |
Returns
Type | Description |
---|---|
NativeArray<T> | A new |
Type Parameters
Name | Description |
---|---|
T | The type of struct to copy. |
Remarks
This is useful for native interops with structs that may change over time. This allows new fields to be added to the C# struct without breaking data obtained from data calls.