Ejemplo n.º 1
0
            /// <summary>
            /// Queries for the set of human body changes.
            /// </summary>
            /// <param name="defaultHumanBody">The default human body.</param>
            /// <param name="allocator">The memory allocator to use for the returns trackable changes.</param>
            /// <returns>
            /// The set of human body changes.
            /// </returns>
            public override unsafe TrackableChanges <XRHumanBody> GetChanges(XRHumanBody defaultHumanBody, Allocator allocator)
            {
                int   numAddedHumanBodies;
                void *addedHumanBodiesPointer;

                int   numUpdatedHumanBodies;
                void *updatedHumanBodiesPointer;

                int   numRemovedHumanBodyIds;
                void *removedHumanBodyIdsPointer;

                int stride;

                var context = NativeApi.UnityARKit_HumanBodyProvider_AcquireChanges(out numAddedHumanBodies, out addedHumanBodiesPointer,
                                                                                    out numUpdatedHumanBodies, out updatedHumanBodiesPointer,
                                                                                    out numRemovedHumanBodyIds, out removedHumanBodyIdsPointer,
                                                                                    out stride);

                try
                {
                    // Wrap the navite pointers into a native array and then copy them into a separate native array enabled
                    // with temporary allocations.
                    return(new TrackableChanges <XRHumanBody>(
                               addedHumanBodiesPointer, numAddedHumanBodies,
                               updatedHumanBodiesPointer, numUpdatedHumanBodies,
                               removedHumanBodyIdsPointer, numRemovedHumanBodyIds,
                               defaultHumanBody, stride,
                               allocator));
                }
                finally
                {
                    NativeApi.UnityARKit_HumanBodyProvider_ReleaseChanges(context);
                }
            }