/// <summary> /// Get the skeleton joints for the requested trackable identifier. /// </summary> /// <param name="trackableId">The human body trackable identifier for which to query.</param> /// <param name="allocator">The memory allocator to use for the returned arrays.</param> /// <param name="skeleton">The array of skeleton joints to update and returns.</param> public override unsafe void GetSkeleton(TrackableId trackableId, Allocator allocator, ref NativeArray <XRHumanBodyJoint> skeleton) { int numJoints; void *joints = NativeApi.UnityARKit_HumanBodyProvider_AcquireJoints(trackableId, out numJoints); try { if (joints == null) { numJoints = 0; } if (!skeleton.IsCreated || (skeleton.Length != numJoints)) { if (skeleton.IsCreated) { skeleton.Dispose(); } skeleton = new NativeArray <XRHumanBodyJoint>(numJoints, allocator); } if (joints != null) { NativeArray <XRHumanBodyJoint> tmp = NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray <XRHumanBodyJoint>(joints, numJoints, Allocator.None); skeleton.CopyFrom(tmp); } } finally { NativeApi.UnityARKit_HumanBodyProvider_ReleaseJoints(joints); } }