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)); } }
public void RegisterToggle(ToggleEx toggle) { if (this.m_Toggles.Contains(toggle)) { return; } this.m_Toggles.Add(toggle); }
public void UnregisterToggle(ToggleEx toggle) { if (!this.m_Toggles.Contains(toggle)) { return; } this.m_Toggles.Remove(toggle); }
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 })); } }
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]; } } }
//註冊的第一位優先開啟 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; } } }
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); } } } }
//回傳開關結果 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); } }
protected virtual void OnToggleValueChanged(ToggleEx _toggle, bool _isOn) { }