示例#1
0
 protected void CertificateToggle(ToggleEx _toggle)
 {
     if (_toggle == null || !m_Toggles.Contains(_toggle))
     {
         throw new ArgumentException(string.Format("ToggleEx : {0} isn't in ToggleExGroup : {1} !", _toggle, this));
     }
 }
示例#2
0
 public void RegisterToggle(ToggleEx toggle)
 {
     if (this.m_Toggles.Contains(toggle))
     {
         return;
     }
     this.m_Toggles.Add(toggle);
 }
示例#3
0
 public void UnregisterToggle(ToggleEx toggle)
 {
     if (!this.m_Toggles.Contains(toggle))
     {
         return;
     }
     this.m_Toggles.Remove(toggle);
 }
示例#4
0
 private void ValidateToggleIsInGroup(ToggleEx toggle)
 {
     if ((UnityEngine.Object)toggle == (UnityEngine.Object)null || !this.m_Toggles.Contains(toggle))
     {
         throw new ArgumentException(string.Format("Toggle {0} is not part of ToggleGroup {1}", new object[2]
         {
             (object)toggle,
             (object)this
         }));
     }
 }
示例#5
0
        public void UnregisterToggle(ToggleEx _toggle)
        {
            if (m_Toggles.Contains(_toggle))
            {
                m_Toggles.Remove(_toggle);
            }

            if (mCurrentToggle == _toggle)
            {
                if (m_Toggles.Count > 0)
                {
                    mCurrentToggle = m_Toggles[0];
                }
            }
        }
示例#6
0
        //註冊的第一位優先開啟
        public void RegisterToggle(ToggleEx _toggle)
        {
            if (!m_Toggles.Contains(_toggle))
            {
                m_Toggles.Add(_toggle);

                if (mCurrentToggle == null)
                {
                    mCurrentToggle = _toggle;
                    _toggle.IsOn   = true;
                }
                else
                {
                    _toggle.IsOn = false;
                }
            }
        }
示例#7
0
        public void NotifyToggleOn(ToggleEx toggle)
        {
            this.ValidateToggleIsInGroup(toggle);

            for (int index = 0; index < this.m_Toggles.Count; ++index)
            {
                if (!((UnityEngine.Object) this.m_Toggles[index] == (UnityEngine.Object)toggle))
                {
                    this.m_Toggles[index].isOn = false;
                }
                else
                {
                    if (toggle.isOn)
                    {
                        onValueChanged.Invoke(index);
                    }
                }
            }
        }
示例#8
0
        //回傳開關結果
        public bool SwitchToggle(ToggleEx _toggle, bool _isOn)
        {
            //理論上不需要檢查
            CertificateToggle(_toggle);

            if (mCurrentToggle == _toggle)
            {
                return(true);
            }
            else
            {
                if (_isOn)
                {
                    mPreviousToggle      = mCurrentToggle;
                    mCurrentToggle       = _toggle;
                    mPreviousToggle.IsOn = false;
                }

                return(_isOn);
            }
        }
示例#9
0
        protected virtual void OnToggleValueChanged(ToggleEx _toggle, bool _isOn)
        {

        }