Version: Unity 6 (6000.0)
LanguageEnglish
  • C#

UnsafeUtility

class in Unity.Collections.LowLevel.Unsafe

/

Implemented in:UnityEngine.CoreModule

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Contains unsafe utility methods.

Static Methods

AddressOfGets the memory address of a struct.
AlignOfGets the minimum alignment of a struct.
ArrayElementAsRefGets a reference to an array element at its current location in memory.
AsReinterprets the reference as a reference of a different type.
AsRefGets a reference to the struct at its current location in memory.
CheckForLeaksGets a list of memory leaks.
CopyObjectAddressToPtrAssigns an object reference to a struct or pinned class.
CopyPtrToStructureCopies sizeof(T) bytes from a memory pointer to a struct.
CopyStructureToPtrCopies sizeof(T) bytes from a memory pointer to a struct.
EnumEqualsDetermines whether specified enums are equal without boxing.
EnumToIntGets the integer representation of an enum value without boxing.
ForgiveLeaksTells the leak checking system to ignore any memory allocations made up to that point.
FreeFree memory.
FreeTrackedFree memory with leak tracking.
GetFieldOffsetReturns the offset of the field relative struct or class it is contained in.
GetLeakDetectionModeGets the mode of memory leak detection.
IsBlittableGets whether a struct is blittable.
IsNativeContainerTypeChecks whether a struct or type is a NativeContainer.
IsUnmanagedChecks whether the struct or type is unmanaged.
IsValidAllocator Returns true if the allocator label is valid and can be used to allocate or deallocate memory.
IsValidNativeContainerElementTypeChecks whether the type is acceptable as an element type in a native container.
MallocAllocate memory.
MallocTrackedAllocate memory with leak tracking.
MemClearClear memory.
MemCmpChecks whether two memory regions are identical.
MemCpyCopy memory.
MemCpyReplicateCopy memory and replicate.
MemCpyStrideSimilar to UnsafeUtility.MemCpy but can skip bytes via desinationStride and sourceStride.
MemMoveMove memory.
MemSetSet memory to specified value.
MemSwapSwap the content of two memory buffers of the same size.
PinGCArrayAndGetDataAddressKeeps a strong GC reference to an array and pins it.
PinGCObjectAndGetAddressKeeps a strong GC reference to an object and pins it.
ReadArrayElementRead array element.
ReadArrayElementWithStrideRead array element with stride.
ReleaseGCObjectReleases a GC Object Handle, previously aquired by UnsafeUtility.PinGCObjectAndGetAddress.
SetLeakDetectionModeSet the leak detection mode.
SizeOfGet the size of struct.
WriteArrayElementWrite array element.
WriteArrayElementWithStrideWrite array element with stride.