Unsafe Utility 类。
AddressOf | 此结构的内存地址。 |
AlignOf | 结构的最小对齐单位。 |
ArrayElementAsRef | Gets a reference to the array element at its current location in memory. |
As | Reinterprets the reference as a reference of a different type. |
AsRef | Gets a reference to the struct at its current location in memory. |
CheckForLeaks | Any memory allocated before this call, that hasn't already been freed, is assumed to have leaked. Prints a list of leaks. |
CopyObjectAddressToPtr | 分配对结构或固定类的对象引用。另请参阅:UnsafeUtility.PinGCObjectAndGetAddress。 |
CopyPtrToStructure | 从 ptr 向 output 复制 sizeof(T) 个字节。 |
CopyStructureToPtr | 从 input 向 ptr 复制 sizeof(T) 个字节。 |
EnumEquals | Determines whether the specified enums are equal without boxing. |
EnumToInt | 返回枚举值的整数表示形式(不装箱)。 |
ForgiveLeaks | Tells the leak checking system to ignore any memory allocations made up to that point - if they leak, they are forgiven. |
Free | 可用内存。 |
FreeTracked | Free memory with leak tracking. |
GetFieldOffset | 返回字段相对于结构或其所在类的偏移。 |
GetLeakDetectionMode | Get whether leak detection is 1=disabled, 2=enabled, or 3=enabled with callstacks. |
IsBlittable | 返回此结构是否可直接复制到本机结构中。 |
IsNativeContainerType | Returns whether the struct or type is a Unity NativeContainer. A NativeContainer type uses the NativeContainerAttribute attribute. |
IsUnmanaged | 返回结构或类型是否为非托管类型。非托管类型不包含托管字段,可以在内存中自由复制。 |
IsValidAllocator | 如果分配器标签有效并且可用来分配或取消分配内存,则返回 true。 |
IsValidNativeContainerElementType | 返回是否可以接受此类型作为原生容器中的元素类型。 |
Malloc | 分配内存。 |
MallocTracked | Allocate memory with leak tracking. |
MemClear | 清除内存。 |
MemCmp | 通过将第一个给定内存缓冲区中的指定内存区域与第二个给定内存缓冲区中的相同区域进行比较,检查两个内存区域是否相同。 |
MemCpy | 复制内存。 |
MemCpyReplicate | 复制内存。 |
MemCpyStride | 与 UnsafeUtility.MemCpy 类似,但可以通过 desinationStride 和 sourceStride 跳过字节。 |
MemMove | 移动内存。 |
MemSet | 将内存设置为指定值。 |
PinGCArrayAndGetDataAddress | 保持对该对象的强 GC 引用并将其固定。保证对象在移动 GC 中的内存位置不会移动。返回数组第一个元素的地址。另请参阅:UnsafeUtility.ReleaseGCObject。 |
PinGCObjectAndGetAddress | 保持对该对象的强 GC 引用并将其固定。保证对象在移动 GC 中的内存位置不会移动。返回该对象的内存位置地址。另请参阅:UnsafeUtility.ReleaseGCObject。 |
ReadArrayElement | 读取数组元素。 |
ReadArrayElementWithStride | 使用步幅读取数组元素。 |
ReleaseGCObject | 释放之前由 UnsafeUtility.PinGCObjectAndGetAddress 获取的 GC 对象句柄。 |
SetLeakDetectionMode | Sets whether leak detection is 1=disabled, 2=enabled, or 3=enabled with callstacks. |
SizeOf | 结构的大小。 |
WriteArrayElement | 写入数组元素。 |
WriteArrayElementWithStride | 使用步幅写入数组元素。 |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.