| | |
| | | using System; |
| | | using UnityEngine.Events; |
| | | |
| | | //点击其他区域触发控制显隐 可附加事件 |
| | | [RequireComponent(typeof(RectTransform))] |
| | | public class ClickScreenOtherSpace : MonoBehaviour |
| | | { |
| | |
| | | case RespondType.In: |
| | | if (RectTransformUtility.RectangleContainsScreenPoint(this.transform as RectTransform, sp, CameraManager.uiCamera)) |
| | | { |
| | | m_ClickOtherEvent?.Invoke(); |
| | | this.SetActive(!m_DeActiveSelf); |
| | | m_ClickOtherEvent?.Invoke(); |
| | | } |
| | | break; |
| | | case RespondType.Out: |
| | | if (!RectTransformUtility.RectangleContainsScreenPoint(this.transform as RectTransform, sp, CameraManager.uiCamera)) |
| | | { |
| | | m_ClickOtherEvent?.Invoke(); |
| | | this.SetActive(!m_DeActiveSelf); |
| | | m_ClickOtherEvent?.Invoke(); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | else if (Input.GetMouseButtonUp(0)) |
| | | { |
| | | switch (m_RespondType) |
| | | { |
| | | case RespondType.InOut: |
| | | m_ClickOtherEvent?.Invoke(); |
| | | this.SetActive(!m_DeActiveSelf); |
| | | m_ClickOtherEvent?.Invoke(); |
| | | break; |
| | | } |
| | | } |