2021년 4학년 1학기 기업연계프로젝트2 컴퓨터소프트웨어공학과 <원광투어팀> 팀장 : 송유진 팀원 : 김나영, 이경희, 한유진
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.

80 lines
3.9 KiB

5 years ago
  1. //========= Copyright 2016-2020, HTC Corporation. All rights reserved. ===========
  2. using HTC.UnityPlugin.Utility;
  3. using System;
  4. using UnityEngine.Events;
  5. namespace HTC.UnityPlugin.VRModuleManagement
  6. {
  7. public partial class VRModule : SingletonBehaviour<VRModule>
  8. {
  9. [Serializable]
  10. public class NewPosesEvent : UnityEvent { }
  11. [Serializable]
  12. public class NewInputEvent : UnityEvent { }
  13. [Serializable]
  14. public class ControllerRoleChangedEvent : UnityEvent { }
  15. [Serializable]
  16. public class InputFocusEvent : UnityEvent<bool> { }
  17. [Serializable]
  18. public class DeviceConnectedEvent : UnityEvent<uint, bool> { }
  19. [Serializable]
  20. public class ActiveModuleChangedEvent : UnityEvent<VRModuleActiveEnum> { }
  21. public delegate void NewPosesListener();
  22. public delegate void NesInputListener();
  23. public delegate void ControllerRoleChangedListener();
  24. public delegate void InputFocusListener(bool value);
  25. public delegate void DeviceConnectedListener(uint deviceIndex, bool connected);
  26. public delegate void ActiveModuleChangedListener(VRModuleActiveEnum activeModule);
  27. private static NewPosesListener s_onNewPoses;
  28. private static NesInputListener s_onNewInput;
  29. private static ControllerRoleChangedListener s_onControllerRoleChanged;
  30. private static InputFocusListener s_onInputFocus;
  31. private static DeviceConnectedListener s_onDeviceConnected;
  32. private static ActiveModuleChangedListener s_onActiveModuleChanged;
  33. public static event NewPosesListener onNewPoses { add { s_onNewPoses += value; } remove { s_onNewPoses -= value; } } // invoke by manager
  34. public static event NesInputListener onNewInput { add { s_onNewInput += value; } remove { s_onNewInput -= value; } } // invoke by manager
  35. public static event ControllerRoleChangedListener onControllerRoleChanged { add { s_onControllerRoleChanged += value; } remove { s_onControllerRoleChanged -= value; } } // invoke by module
  36. public static event InputFocusListener onInputFocus { add { s_onInputFocus += value; } remove { s_onInputFocus -= value; } } // invoke by module
  37. public static event DeviceConnectedListener onDeviceConnected { add { s_onDeviceConnected += value; } remove { s_onDeviceConnected -= value; } }// invoke by manager
  38. public static event ActiveModuleChangedListener onActiveModuleChanged { add { s_onActiveModuleChanged += value; } remove { s_onActiveModuleChanged -= value; } } // invoke by manager
  39. private static void InvokeNewPosesEvent()
  40. {
  41. if (s_onNewPoses != null) { s_onNewPoses(); }
  42. if (Active) { Instance.m_onNewPoses.Invoke(); }
  43. }
  44. private static void InvokeNewInputEvent()
  45. {
  46. if (s_onNewInput != null) { s_onNewInput(); }
  47. if (Active) { Instance.m_onNewInput.Invoke(); }
  48. }
  49. private static void InvokeControllerRoleChangedEvent()
  50. {
  51. if (s_onControllerRoleChanged != null) { s_onControllerRoleChanged(); }
  52. if (Active) { Instance.m_onControllerRoleChanged.Invoke(); }
  53. }
  54. private static void InvokeInputFocusEvent(bool value)
  55. {
  56. if (s_onInputFocus != null) { s_onInputFocus(value); }
  57. if (Active) { Instance.m_onInputFocus.Invoke(value); }
  58. }
  59. private static void InvokeDeviceConnectedEvent(uint deviceIndex, bool connected)
  60. {
  61. if (s_onDeviceConnected != null) { s_onDeviceConnected(deviceIndex, connected); }
  62. if (Active) { Instance.m_onDeviceConnected.Invoke(deviceIndex, connected); }
  63. }
  64. private static void InvokeActiveModuleChangedEvent(VRModuleActiveEnum activeModule)
  65. {
  66. if (s_onActiveModuleChanged != null) { s_onActiveModuleChanged(activeModule); }
  67. if (Active) { Instance.m_onActiveModuleChanged.Invoke(activeModule); }
  68. }
  69. }
  70. }