NativeButtonVoice.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using UnityEngine;
  2. using Rokid.UXR.Interaction;
  3. namespace Rokid.UXR.Utility
  4. {
  5. public class NativeButtonVoice : MonoBehaviour
  6. {
  7. private InteractorButton button;
  8. private RKButton rkButton;
  9. private void Start()
  10. {
  11. //RKButton优先
  12. rkButton = GetComponent<RKButton>();
  13. if (rkButton != null)
  14. {
  15. rkButton?.onPointerClick.AddListener(data =>
  16. {
  17. NativeAudioPlay.Instance.PlayAudioButtonClick();
  18. });
  19. rkButton?.onPointerDown.AddListener(data =>
  20. {
  21. NativeAudioPlay.Instance.PlayAudioButtonDown();
  22. });
  23. }
  24. else
  25. {
  26. button = GetComponent<InteractorButton>();
  27. button?.onPointerClick.AddListener(data =>
  28. {
  29. NativeAudioPlay.Instance.PlayAudioButtonClick();
  30. });
  31. button?.onPointerDown.AddListener(data =>
  32. {
  33. NativeAudioPlay.Instance.PlayAudioButtonDown();
  34. });
  35. }
  36. }
  37. }
  38. }