From b0a5d4688f1af73b5ad03ccc2df11c9aac1523a9 Mon Sep 17 00:00:00 2001 From: yyl <yyl> Date: 星期二, 29 七月 2025 16:56:23 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.1.20:10010/r/Project_SG_scripts --- Main/Component/UI/Common/FunctionButton.cs | 480 ++++++++++++++++++++++++++++++------------------------------ 1 files changed, 240 insertions(+), 240 deletions(-) diff --git a/Main/Component/UI/Common/FunctionButton.cs b/Main/Component/UI/Common/FunctionButton.cs index b4718f1..965bae3 100644 --- a/Main/Component/UI/Common/FunctionButton.cs +++ b/Main/Component/UI/Common/FunctionButton.cs @@ -11,249 +11,249 @@ using System; - - public class FunctionButton : Button - { - [SerializeField] int m_Order = 0; - public int order { - get { return m_Order; } - set { - m_Order = value; - } +//鍏宠仈娓告垙鐜╂硶鍔熻兘鎸夐挳锛屽鍗囨槦鍔熻兘 +public class FunctionButton : Button +{ + [SerializeField] int m_Order = 0; + public int order { + get { return m_Order; } + set { + m_Order = value; } - - [SerializeField] int m_FunctionId = -1; - public int functionId { - get { return m_FunctionId; } - set { - m_FunctionId = value; - OnFunctionUnLockStateChange(); - } - } - - [SerializeField] TitleBtnState m_State = TitleBtnState.Normal; - public TitleBtnState state { - get { return m_State; } - set { - if (m_State != value) - { - m_State = value; - OnStateChange(); - } - } - } - - [SerializeField] Button m_Button; - public Button button { - get { return m_Button; } - set { m_Button = value; } - } - - [SerializeField] ImageEx m_Icon; - public ImageEx icon { - get { return this.m_Icon; } - set { this.m_Icon = value; } - } - - [SerializeField] TextEx m_Title; - public TextEx title { - get { return this.m_Title; } - set { this.m_Title = value; } - } - - [SerializeField] RedpointBehaviour m_Redpoint; - public RedpointBehaviour redpoint { - get { return m_Redpoint; } - set { m_Redpoint = value; } - } - - [SerializeField] Shadow m_Shadow; - public Shadow shadow { - get { return this.m_Shadow; } - set { this.m_Shadow = value; } - } - - [SerializeField] Transform m_Locked; - public Transform locked { - get { return this.m_Locked; } - set { this.m_Locked = value; } - } - - [SerializeField] int m_Audio = 1; - public int clickAudio { - get { return this.m_Audio; } - set { this.m_Audio = value; } - } - - [SerializeField] bool m_UseDefaultConfig = true; - public bool useDefaultConfig { - get { return this.m_UseDefaultConfig; } - set { this.m_UseDefaultConfig = value; } - } - - [SerializeField] FunctionButtonConfig m_AlternativeConfig; - public FunctionButtonConfig alternativeConfig { get { return m_AlternativeConfig; } set { m_AlternativeConfig = value; } } - - [SerializeField] - FunctionButtonGroup m_Group; - public FunctionButtonGroup group { - get { return m_Group; } - set { - if (m_Group != null) - { - m_Group.UnRegister(this); - } - m_Group = value; - if (m_Group != null) - { - m_Group.Register(this); - } - } - } - - public event Action<string> OnPointClickLockFunc; - public event Action repeatClickFunc; - - protected override void Awake() - { -#if UNITY_EDITOR - if (!Application.isPlaying) return; -#endif - OnFunctionUnLockStateChange(); - FuncOpen.Instance.OnFuncStateChangeEvent += OnFunctionUnLockStateChange; - } - - protected override void OnEnable() - { - base.OnEnable(); - - if (group != null) - { - group.Register(this); - } - - OnStateChange(); - } - - protected override void OnDisable() - { - base.OnDisable(); - - if (group != null) - { - group.UnRegister(this); - } - } - - protected override void OnDestroy() - { -#if UNITY_EDITOR - if (!Application.isPlaying) return; -#endif - FuncOpen.Instance.OnFuncStateChangeEvent -= OnFunctionUnLockStateChange; - } - - bool invokeForce = false; - - public void Invoke(bool _force) - { - invokeForce = _force; - OnPointerClick(null); - invokeForce = false; - } - - public override void OnPointerClick(PointerEventData eventData) - { - if (state == TitleBtnState.Locked) - { - if (OnPointClickLockFunc != null) - { - OnPointClickLockFunc(this.gameObject.name); - } - else - { - FuncOpen.Instance.ProcessorFuncErrorTip(functionId); - } - return; - } - - if (!invokeForce && state == TitleBtnState.Click) - { - if (repeatClickFunc != null) - { - repeatClickFunc(); - } - return; - } - - if (base.onClick != null) - { - base.onClick.Invoke(); - if (eventData != null) - { - SoundPlayer.Instance.PlayUIAudio(clickAudio); - } - } - - state = TitleBtnState.Click; - } - - private void OnStateChange() - { - var config = useDefaultConfig ? FunctionButtonConfig.GetDefault() : m_AlternativeConfig; - if (Application.isPlaying) - { - icon.SetSprite(config.GetIconKey(state)); - } - - title.color = config.GetFontColor(state); - title.fontSize = config.GetFontSize(state); - - if (shadow != null) - { - shadow.enabled = state == TitleBtnState.Locked || state == TitleBtnState.Normal; - } - - if (locked != null) - { - locked.SetActive(state == TitleBtnState.Locked); - } - - if (group != null && state == TitleBtnState.Click) - { - group.NotifyToggleOn(this); - } - } - - private void OnFunctionUnLockStateChange(int _functionId) - { - if (m_FunctionId == _functionId) - { - OnFunctionUnLockStateChange(); - } - } - - private void OnFunctionUnLockStateChange() - { - if (m_FunctionId == 0) - { - return; - } - - var isOpen = m_FunctionId == -1 || FuncOpen.Instance.IsFuncOpen(m_FunctionId); - state = isOpen ? state == TitleBtnState.Click ? TitleBtnState.Click : TitleBtnState.Normal : TitleBtnState.Locked; - } - -#if UNITY_EDITOR - protected override void OnValidate() - { - base.OnValidate(); - OnStateChange(); - } -#endif - } + [SerializeField] int m_FunctionId = -1; + public int functionId { + get { return m_FunctionId; } + set { + m_FunctionId = value; + OnFunctionUnLockStateChange(); + } + } + + [SerializeField] TitleBtnState m_State = TitleBtnState.Normal; + public TitleBtnState state { + get { return m_State; } + set { + if (m_State != value) + { + m_State = value; + OnStateChange(); + } + } + } + + [SerializeField] Button m_Button; + public Button button { + get { return m_Button; } + set { m_Button = value; } + } + + [SerializeField] ImageEx m_Icon; + public ImageEx icon { + get { return this.m_Icon; } + set { this.m_Icon = value; } + } + + [SerializeField] TextEx m_Title; + public TextEx title { + get { return this.m_Title; } + set { this.m_Title = value; } + } + + [SerializeField] RedpointBehaviour m_Redpoint; + public RedpointBehaviour redpoint { + get { return m_Redpoint; } + set { m_Redpoint = value; } + } + + [SerializeField] Shadow m_Shadow; + public Shadow shadow { + get { return this.m_Shadow; } + set { this.m_Shadow = value; } + } + + [SerializeField] Transform m_Locked; + public Transform locked { + get { return this.m_Locked; } + set { this.m_Locked = value; } + } + + [SerializeField] int m_Audio = 1; + public int clickAudio { + get { return this.m_Audio; } + set { this.m_Audio = value; } + } + + [SerializeField] bool m_UseDefaultConfig = true; + public bool useDefaultConfig { + get { return this.m_UseDefaultConfig; } + set { this.m_UseDefaultConfig = value; } + } + + [SerializeField] FunctionButtonConfig m_AlternativeConfig; + public FunctionButtonConfig alternativeConfig { get { return m_AlternativeConfig; } set { m_AlternativeConfig = value; } } + + [SerializeField] + FunctionButtonGroup m_Group; + public FunctionButtonGroup group { + get { return m_Group; } + set { + if (m_Group != null) + { + m_Group.UnRegister(this); + } + m_Group = value; + if (m_Group != null) + { + m_Group.Register(this); + } + } + } + + public event Action<string> OnPointClickLockFunc; + public event Action repeatClickFunc; + + protected override void Awake() + { +#if UNITY_EDITOR + if (!Application.isPlaying) return; +#endif + OnFunctionUnLockStateChange(); + FuncOpen.Instance.OnFuncStateChangeEvent += OnFunctionUnLockStateChange; + } + + protected override void OnEnable() + { + base.OnEnable(); + + if (group != null) + { + group.Register(this); + } + + OnStateChange(); + } + + protected override void OnDisable() + { + base.OnDisable(); + + if (group != null) + { + group.UnRegister(this); + } + } + + protected override void OnDestroy() + { +#if UNITY_EDITOR + if (!Application.isPlaying) return; +#endif + FuncOpen.Instance.OnFuncStateChangeEvent -= OnFunctionUnLockStateChange; + } + + bool invokeForce = false; + + public void Invoke(bool _force) + { + invokeForce = _force; + OnPointerClick(null); + invokeForce = false; + } + + public override void OnPointerClick(PointerEventData eventData) + { + if (state == TitleBtnState.Locked) + { + if (OnPointClickLockFunc != null) + { + OnPointClickLockFunc(this.gameObject.name); + } + else + { + FuncOpen.Instance.ProcessorFuncErrorTip(functionId); + } + return; + } + + if (!invokeForce && state == TitleBtnState.Click) + { + if (repeatClickFunc != null) + { + repeatClickFunc(); + } + return; + } + + if (base.onClick != null) + { + base.onClick.Invoke(); + if (eventData != null) + { + SoundPlayer.Instance.PlayUIAudio(clickAudio); + } + } + + state = TitleBtnState.Click; + } + + private void OnStateChange() + { + var config = useDefaultConfig ? FunctionButtonConfig.GetDefault() : m_AlternativeConfig; + if (Application.isPlaying) + { + icon.SetSprite(config.GetIconKey(state)); + } + + title.color = config.GetFontColor(state); + title.fontSize = config.GetFontSize(state); + + if (shadow != null) + { + shadow.enabled = state == TitleBtnState.Locked || state == TitleBtnState.Normal; + } + + if (locked != null) + { + locked.SetActive(state == TitleBtnState.Locked); + } + + if (group != null && state == TitleBtnState.Click) + { + group.NotifyToggleOn(this); + } + } + + private void OnFunctionUnLockStateChange(int _functionId) + { + if (m_FunctionId == _functionId) + { + OnFunctionUnLockStateChange(); + } + } + + private void OnFunctionUnLockStateChange() + { + if (m_FunctionId == 0) + { + return; + } + + var isOpen = m_FunctionId == -1 || FuncOpen.Instance.IsFuncOpen(m_FunctionId); + state = isOpen ? state == TitleBtnState.Click ? TitleBtnState.Click : TitleBtnState.Normal : TitleBtnState.Locked; + } + +#if UNITY_EDITOR + protected override void OnValidate() + { + base.OnValidate(); + OnStateChange(); + } +#endif + +} + -- Gitblit v1.8.0