| 1 | using UnityEngine; |
| 2 | using System.Collections; |
| 3 | using System.Collections.Generic; |
| 4 | using System; |
| 5 | using Oculus.Avatar; |
| 6 | |
| 7 | public class OvrAvatarHand : OvrAvatarComponent |
| 8 | { |
| 9 | public bool isLeftHand = true; |
| 10 | ovrAvatarHandComponent component = new ovrAvatarHandComponent(); |
| 11 | |
| 12 | void Update() |
| 13 | { |
| 14 | if (owner == null) |
| 15 | { |
| 16 | return; |
| 17 | } |
| 18 | |
| 19 | bool hasComponent = false; |
| 20 | if (isLeftHand) |
| 21 | { |
| 22 | hasComponent = CAPI.ovrAvatarPose_GetLeftHandComponent(owner.sdkAvatar, ref component); |
| 23 | } |
| 24 | else |
| 25 | { |
| 26 | hasComponent = CAPI.ovrAvatarPose_GetRightHandComponent(owner.sdkAvatar, ref component); |
| 27 | } |
| 28 | |
| 29 | if (hasComponent) |
| 30 | { |
| 31 | UpdateAvatar(component.renderComponent); |
| 32 | } |
| 33 | else |
| 34 | { |
| 35 | if (isLeftHand) |
| 36 | { |
| 37 | owner.HandLeft = null; |
| 38 | |
| 39 | } |
| 40 | else |
| 41 | { |
| 42 | owner.HandRight = null; |
| 43 | } |
| 44 | |
| 45 | Destroy(this); |
| 46 | } |
| 47 | } |
| 48 | } |