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.

43 lines
996 B

  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. public ovrAvatarComponent? GetNativeAvatarComponent()
  10. {
  11. if (owner == null)
  12. {
  13. return null;
  14. }
  15. if (CAPI.ovrAvatarPose_GetBodyComponent(owner.sdkAvatar, ref component))
  16. {
  17. CAPI.ovrAvatarComponent_Get(component.renderComponent, true, ref nativeAvatarComponent);
  18. return nativeAvatarComponent;
  19. }
  20. return null;
  21. }
  22. void Update()
  23. {
  24. if (owner == null)
  25. {
  26. return;
  27. }
  28. if (CAPI.ovrAvatarPose_GetBodyComponent(owner.sdkAvatar, ref component))
  29. {
  30. UpdateAvatar(component.renderComponent);
  31. }
  32. else
  33. {
  34. owner.Body = null;
  35. Destroy(this);
  36. }
  37. }
  38. }