API_Module_SafetyArea.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class API_Module_SafetyArea
  6. {
  7. /// <summary>
  8. /// 进入安全区域时的回调注册
  9. /// </summary>
  10. /// <param name="callback"></param>
  11. public static void RegistSafetyAreaEnterCallback(Action callback)
  12. {
  13. SafetyAreaManager.Instance.OnEnterSafetyArea += callback;
  14. }
  15. /// <summary>
  16. /// 进入安全区域时的回调注销
  17. /// </summary>
  18. /// <param name="callback"></param>
  19. public static void UnRegistSafetyAreaEnterCallback(Action callback)
  20. {
  21. SafetyAreaManager.Instance.OnEnterSafetyArea -= callback;
  22. }
  23. /// <summary>
  24. /// 退出安全区域时的回调注册
  25. /// </summary>
  26. /// <param name="callback"></param>
  27. public static void RegistSafetyAreaExitCallback(Action callback)
  28. {
  29. SafetyAreaManager.Instance.OnExitSafetyArea += callback;
  30. }
  31. /// <summary>
  32. /// 退出安全区域时的回调注销
  33. /// </summary>
  34. /// <param name="callback"></param>
  35. public static void UnRegistSafetyAreaExitCallback(Action callback)
  36. {
  37. SafetyAreaManager.Instance.OnExitSafetyArea += callback;
  38. }
  39. /// <summary>
  40. /// 开始设置安全区域时的回调注册
  41. /// </summary>
  42. /// <param name="callback"></param>
  43. public static void RegistSafetyAreaStartCallback(Action callback)
  44. {
  45. SafetyAreaManager.Instance.OnBeginSetSafeArea += callback;
  46. }
  47. /// <summary>
  48. /// 开始设置安全区域时的回调注销
  49. /// </summary>
  50. /// <param name="callback"></param>
  51. public static void UnRegistSafetyAreaStartCallback(Action callback)
  52. {
  53. SafetyAreaManager.Instance.OnBeginSetSafeArea -= callback;
  54. }
  55. /// <summary>
  56. /// 完成设置安全区域时的回调注册
  57. /// </summary>
  58. /// <param name="callback"></param>
  59. public static void RegistSafetyAreaFinishCallback(Action callback)
  60. {
  61. SafetyAreaManager.Instance.OnFinishSetSafeArea += callback;
  62. }
  63. /// <summary>
  64. /// 完成设置安全区域时的回调注销
  65. /// </summary>
  66. /// <param name="callback"></param>
  67. public static void UnRegistSafetyAreaFinishCallback(Action callback)
  68. {
  69. SafetyAreaManager.Instance.OnFinishSetSafeArea += callback;
  70. }
  71. /// <summary>
  72. /// 开始设置安全区域
  73. /// </summary>
  74. public static void StartSetSafetyArea()
  75. {
  76. SafetyAreaManager.Instance.StartSetSafetyArea();
  77. }
  78. /// <summary>
  79. /// 重新设置区域高度(如果没有安全区域则会重新设置)
  80. /// </summary>
  81. public static void StartSetSafetyAreaHeight()
  82. {
  83. SafetyAreaManager.Instance.StartSetSafetyAreaHeight();
  84. }
  85. /// <summary>
  86. /// 获取安全区域颜色
  87. /// </summary>
  88. /// <returns></returns>
  89. public static int GetSafetyAreaColor()
  90. {
  91. return SafetyAreaManager.Instance.OriginSafetyAreaColorIndex;
  92. }
  93. /// <summary>
  94. /// 设置安全区域颜色
  95. /// </summary>
  96. /// <param name="color"></param>
  97. public static void SetSafetyAreaColor(int index)
  98. {
  99. SafetyAreaManager.Instance.OriginSafetyAreaColorIndex = index;
  100. }
  101. /// <summary>
  102. /// 获取低头是否显示安全区域
  103. /// </summary>
  104. /// <returns></returns>
  105. public static bool GetShowAreaWhenBowHead()
  106. {
  107. return SafetyAreaManager.Instance.ShowAreaWhenBowHead;
  108. }
  109. /// <summary>
  110. /// 低头时是否显示游戏区域轮廓
  111. /// </summary>
  112. /// <param name="isOpen"></param>
  113. public static void SetShowAreaWhenBowHead(bool isOpen)
  114. {
  115. SafetyAreaManager.Instance.ShowAreaWhenBowHead = isOpen;
  116. }
  117. /// <summary>
  118. /// 获取灵敏度
  119. /// </summary>
  120. /// <returns></returns>
  121. public static float GetSensitivity()
  122. {
  123. return SafetyAreaManager.Instance.OriginAlphaParam;
  124. }
  125. /// <summary>
  126. /// 设置安全区域灵敏度 范围0~1
  127. /// </summary>
  128. /// <param name="value"></param>
  129. public static void SetSensitivity(float value)
  130. {
  131. SafetyAreaManager.Instance.OriginAlphaParam = value;
  132. }
  133. /// <summary>
  134. /// 删除已有的原地区域
  135. /// </summary>
  136. public static void DestroySafetyArea()
  137. {
  138. SafetyAreaManager.Instance.DestroySafetyArea();
  139. }
  140. /// <summary>
  141. /// 禁用安全区域显示
  142. /// </summary>
  143. /// <param name="isDisable"></param>
  144. public static void DisableSafetyAreaDisplay(bool isDisable)
  145. {
  146. SafetyAreaManager.Instance.IsDisableSafetyArea = isDisable;
  147. }
  148. /// <summary>
  149. /// 查看是否可以双击查看SeeThroguh
  150. /// </summary>
  151. /// <returns></returns>
  152. public static bool CheckDoubleTapSeeThrough()
  153. {
  154. return SafetyAreaManager.Instance.DoubleClickShowSeeThrough;
  155. }
  156. /// <summary>
  157. /// 设置双击查看SeeThrough
  158. /// </summary>
  159. /// <param name="isOn"></param>
  160. public static void SetDouleTapSeeThrough(bool isOn)
  161. {
  162. SafetyAreaManager.Instance.DoubleClickShowSeeThrough = isOn;
  163. }
  164. /// <summary>
  165. /// 获取安全区域类型
  166. /// </summary>
  167. /// <returns></returns>
  168. public static SafetyAreaTypeEnum GetSafetyAreaType()
  169. {
  170. return SafetyAreaManager.Instance.GetSafetyAreaType();
  171. }
  172. /// <summary>
  173. /// 设置过程中强制关闭
  174. /// </summary>
  175. public static void CancelSafetyArea()
  176. {
  177. SafetyAreaManager.Instance.UserCancelStep();
  178. }
  179. }