SkeletonUIOptions.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //======= Copyright (c) Valve Corporation, All rights reserved. ===============
  2. using UnityEngine;
  3. using System.Collections;
  4. using Valve.VR.InteractionSystem;
  5. namespace Valve.VR.InteractionSystem.Sample
  6. {
  7. public class SkeletonUIOptions : MonoBehaviour
  8. {
  9. public void AnimateHandWithController()
  10. {
  11. for (int handIndex = 0; handIndex < Player.instance.hands.Length; handIndex++)
  12. {
  13. Hand hand = Player.instance.hands[handIndex];
  14. if (hand != null)
  15. {
  16. hand.SetSkeletonRangeOfMotion(Valve.VR.EVRSkeletalMotionRange.WithController);
  17. }
  18. }
  19. }
  20. public void AnimateHandWithoutController()
  21. {
  22. for (int handIndex = 0; handIndex < Player.instance.hands.Length; handIndex++)
  23. {
  24. Hand hand = Player.instance.hands[handIndex];
  25. if (hand != null)
  26. {
  27. hand.SetSkeletonRangeOfMotion(Valve.VR.EVRSkeletalMotionRange.WithoutController);
  28. }
  29. }
  30. }
  31. public void ShowController()
  32. {
  33. for (int handIndex = 0; handIndex < Player.instance.hands.Length; handIndex++)
  34. {
  35. Hand hand = Player.instance.hands[handIndex];
  36. if (hand != null)
  37. {
  38. hand.ShowController(true);
  39. }
  40. }
  41. }
  42. public void SetRenderModel(RenderModelChangerUI prefabs)
  43. {
  44. for (int handIndex = 0; handIndex < Player.instance.hands.Length; handIndex++)
  45. {
  46. Hand hand = Player.instance.hands[handIndex];
  47. if (hand != null)
  48. {
  49. if (hand.handType == SteamVR_Input_Sources.RightHand)
  50. hand.SetRenderModel(prefabs.rightPrefab);
  51. if (hand.handType == SteamVR_Input_Sources.LeftHand)
  52. hand.SetRenderModel(prefabs.leftPrefab);
  53. }
  54. }
  55. }
  56. public void HideController()
  57. {
  58. for (int handIndex = 0; handIndex < Player.instance.hands.Length; handIndex++)
  59. {
  60. Hand hand = Player.instance.hands[handIndex];
  61. if (hand != null)
  62. {
  63. hand.HideController(true);
  64. }
  65. }
  66. }
  67. }
  68. }