SW 중심대학 OSS GIT 서버 박건태, 이승준, 고기완, 이준호 새로운 배포
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
859 B

4 years ago
  1. using System;
  2. using System.Runtime.InteropServices;
  3. using Unity.Collections;
  4. using Unity.Collections.LowLevel.Unsafe;
  5. namespace UnityEngine.XR.ARCore
  6. {
  7. /// <summary>
  8. /// Similar to NativeSlice but blittable. Provides a "view"
  9. /// into a contiguous array of memory. Used to interop with C.
  10. /// </summary>
  11. [StructLayout(LayoutKind.Sequential)]
  12. internal unsafe struct NativeView
  13. {
  14. void* m_Ptr;
  15. int m_Length;
  16. public NativeView(void* ptr, int length)
  17. {
  18. m_Ptr = ptr;
  19. m_Length = length;
  20. }
  21. public static NativeView Create<T>(NativeArray<T> array) where T : struct => new NativeView(array.GetUnsafePtr(), array.Length);
  22. public static NativeView Create<T>(NativeSlice<T> slice) where T : struct => new NativeView(slice.GetUnsafePtr(), slice.Length);
  23. }
  24. }