CUI_ViveHapticPulse.cs 705 B

123456789101112131415161718192021222324252627282930
  1. using UnityEngine;
  2. using System.Collections;
  3. namespace CurvedUI {
  4. public class CUI_ViveHapticPulse : MonoBehaviour
  5. {
  6. #pragma warning disable 414 // this is just so we wont get "unused variable" code warnings when compiling without Vive.
  7. float PulseStrength;
  8. #pragma warning restore 414
  9. void Start()
  10. {
  11. PulseStrength = 1;
  12. }
  13. public void SetPulseStrength(float newStr)
  14. {
  15. PulseStrength = Mathf.Clamp(newStr, 0, 1);
  16. }
  17. public void TriggerPulse()
  18. {
  19. #if CURVEDUI_STEAMVR_LEGACY
  20. CurvedUIInputModule.Right.TriggerHapticPulse(1, (ushort)(PulseStrength * 3000));
  21. #endif
  22. }
  23. }
  24. }