From 61b188e1d59af9a1e3b4f005bd4b9211b2db97d8 Mon Sep 17 00:00:00 2001 From: yyl <yyl> Date: 星期四, 09 十月 2025 15:46:31 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.1.20:10010/r/Project_SG_scripts --- Main/Component/UI/Common/ClickScreenOtherSpace.cs | 108 ++++++++++++++++++++++++++++++------------------------ 1 files changed, 60 insertions(+), 48 deletions(-) diff --git a/Main/Component/UI/Common/ClickScreenOtherSpace.cs b/Main/Component/UI/Common/ClickScreenOtherSpace.cs index d9e96d1..a0a701a 100644 --- a/Main/Component/UI/Common/ClickScreenOtherSpace.cs +++ b/Main/Component/UI/Common/ClickScreenOtherSpace.cs @@ -5,59 +5,71 @@ using System; using UnityEngine.Events; - [RequireComponent(typeof(RectTransform))] - public class ClickScreenOtherSpace : MonoBehaviour +[RequireComponent(typeof(RectTransform))] +public class ClickScreenOtherSpace : MonoBehaviour +{ + [SerializeField] + bool m_DeActiveSelf = true; + public bool deActiveSelf { + get { return m_DeActiveSelf; } + set { m_DeActiveSelf = value; } + } + + [SerializeField] + RespondType m_RespondType = RespondType.Out; + public RespondType respondType { + get { return m_RespondType; } + set { m_RespondType = value; } + } + + Action m_ClickOtherEvent; + + public void AddListener(Action _callBack) { - [SerializeField] - bool m_DeActiveSelf = true; - public bool deActiveSelf { - get { return m_DeActiveSelf; } - set { m_DeActiveSelf = value; } - } + m_ClickOtherEvent = null; + m_ClickOtherEvent += _callBack; + } - [SerializeField] - RespondType m_RespondType = RespondType.Out; - public RespondType respondType { - get { return m_RespondType; } - set { m_RespondType = value; } - } + public void RemoveAllListeners() + { + m_ClickOtherEvent = null; + } - Action m_ClickOtherEvent; - public void AddListener(Action _callBack) + private void LateUpdate() + { + if (Input.GetMouseButtonDown(0)) { - m_ClickOtherEvent += _callBack; - } - - public void RemoveAllListeners() - { - m_ClickOtherEvent = null; - } - - private void LateUpdate() - { - if (Input.GetMouseButtonDown(0)) { - var sp = Input.mousePosition; - switch (m_RespondType) { - case RespondType.In: - if (RectTransformUtility.RectangleContainsScreenPoint(this.transform as RectTransform, sp, CameraManager.uiCamera)) { - m_ClickOtherEvent?.Invoke(); - this.SetActive(!m_DeActiveSelf); - } - break; - case RespondType.Out: - if (!RectTransformUtility.RectangleContainsScreenPoint(this.transform as RectTransform, sp, CameraManager.uiCamera)) { - m_ClickOtherEvent?.Invoke(); - this.SetActive(!m_DeActiveSelf); - } - break; - } + var sp = Input.mousePosition; + switch (m_RespondType) + { + case RespondType.In: + if (RectTransformUtility.RectangleContainsScreenPoint(this.transform as RectTransform, sp, CameraManager.uiCamera)) + { + m_ClickOtherEvent?.Invoke(); + this.SetActive(!m_DeActiveSelf); + } + break; + case RespondType.Out: + if (!RectTransformUtility.RectangleContainsScreenPoint(this.transform as RectTransform, sp, CameraManager.uiCamera)) + { + m_ClickOtherEvent?.Invoke(); + this.SetActive(!m_DeActiveSelf); + } + break; + case RespondType.InOut: + m_ClickOtherEvent?.Invoke(); + this.SetActive(!m_DeActiveSelf); + break; } } + } - public enum RespondType - { - In, - Out, - } - } \ No newline at end of file + public enum RespondType + { + In, + Out, + InOut + + } +} \ No newline at end of file -- Gitblit v1.8.0