Assignment for RMIT Mixed Reality in 2020
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.

48 lines
1.0 KiB

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