| 1 | using UnityEngine; |
| 2 | using System.Collections; |
| 3 | using System.Collections.Generic; |
| 4 | using System; |
| 5 | using Oculus.Avatar; |
| 6 | public class OvrAvatarBody : OvrAvatarComponent |
| 7 | { |
| 8 | public ovrAvatarBodyComponent component = new ovrAvatarBodyComponent(); |
| 9 | |
| 10 | public ovrAvatarComponent? GetNativeAvatarComponent() |
| 11 | { |
| 12 | if (owner == null) |
| 13 | { |
| 14 | return null; |
| 15 | } |
| 16 | |
| 17 | if (CAPI.ovrAvatarPose_GetBodyComponent(owner.sdkAvatar, ref component)) |
| 18 | { |
| 19 | CAPI.ovrAvatarComponent_Get(component.renderComponent, true, ref nativeAvatarComponent); |
| 20 | return nativeAvatarComponent; |
| 21 | } |
| 22 | |
| 23 | return null; |
| 24 | } |
| 25 | |
| 26 | void Update() |
| 27 | { |
| 28 | if (owner == null) |
| 29 | { |
| 30 | return; |
| 31 | } |
| 32 | |
| 33 | if (CAPI.ovrAvatarPose_GetBodyComponent(owner.sdkAvatar, ref component)) |
| 34 | { |
| 35 | UpdateAvatar(component.renderComponent); |
| 36 | } |
| 37 | else |
| 38 | { |
| 39 | owner.Body = null; |
| 40 | Destroy(this); |
| 41 | } |
| 42 | } |
| 43 | } |