fix
This commit is contained in:
parent
761b7b1827
commit
289bfc6111
@ -94,7 +94,20 @@ public class UXButton : UIBehaviour, IButton,
|
|||||||
public bool Selected
|
public bool Selected
|
||||||
{
|
{
|
||||||
get => _mTogSelected;
|
get => _mTogSelected;
|
||||||
internal set
|
set
|
||||||
|
{
|
||||||
|
if ((m_Mode == ButtonModeType.Normal && value) || m_Mode == ButtonModeType.Toggle)
|
||||||
|
{
|
||||||
|
if (m_Mode == ButtonModeType.Toggle) _mTogSelected = !value;
|
||||||
|
HandleClick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal bool InternalTogSelected
|
||||||
|
{
|
||||||
|
get => _mTogSelected;
|
||||||
|
set
|
||||||
{
|
{
|
||||||
if (_mTogSelected == value) return;
|
if (_mTogSelected == value) return;
|
||||||
_mTogSelected = value;
|
_mTogSelected = value;
|
||||||
@ -223,7 +236,7 @@ public class UXButton : UIBehaviour, IButton,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Selected = !Selected;
|
InternalTogSelected = !Selected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -30,7 +30,7 @@ public class UXGroup : UIBehaviour
|
|||||||
{
|
{
|
||||||
foreach (var btn in m_Buttons)
|
foreach (var btn in m_Buttons)
|
||||||
if (btn)
|
if (btn)
|
||||||
btn.Selected = false;
|
btn.InternalTogSelected = false;
|
||||||
m_Buttons.Clear();
|
m_Buttons.Clear();
|
||||||
base.OnDestroy();
|
base.OnDestroy();
|
||||||
}
|
}
|
||||||
@ -41,10 +41,10 @@ public class UXGroup : UIBehaviour
|
|||||||
if (m_Buttons.Contains(button)) return;
|
if (m_Buttons.Contains(button)) return;
|
||||||
m_Buttons.Add(button);
|
m_Buttons.Add(button);
|
||||||
|
|
||||||
if (button.Selected)
|
if (button.InternalTogSelected)
|
||||||
{
|
{
|
||||||
if (_current && _current != button)
|
if (_current && _current != button)
|
||||||
_current.Selected = false;
|
_current.InternalTogSelected = false;
|
||||||
_current = button;
|
_current = button;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,14 +57,14 @@ public class UXGroup : UIBehaviour
|
|||||||
m_Buttons.Remove(button);
|
m_Buttons.Remove(button);
|
||||||
if (_current == button)
|
if (_current == button)
|
||||||
_current = null;
|
_current = null;
|
||||||
button.Selected = false;
|
button.InternalTogSelected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void NotifyButtonClicked(UXButton button)
|
internal void NotifyButtonClicked(UXButton button)
|
||||||
{
|
{
|
||||||
if (!button) return;
|
if (!button) return;
|
||||||
|
|
||||||
if (button.Selected)
|
if (button.InternalTogSelected)
|
||||||
{
|
{
|
||||||
if (m_AllowSwitchOff) SetSelected(null);
|
if (m_AllowSwitchOff) SetSelected(null);
|
||||||
}
|
}
|
||||||
@ -76,14 +76,15 @@ public class UXGroup : UIBehaviour
|
|||||||
|
|
||||||
private void SetSelected(UXButton target)
|
private void SetSelected(UXButton target)
|
||||||
{
|
{
|
||||||
|
if (_current == target) return;
|
||||||
var previous = _current;
|
var previous = _current;
|
||||||
_current = null;
|
_current = null;
|
||||||
|
|
||||||
foreach (var btn in m_Buttons)
|
foreach (var btn in m_Buttons)
|
||||||
{
|
{
|
||||||
bool select = (btn == target);
|
bool select = (btn == target);
|
||||||
if (btn.Selected != select)
|
if (btn.InternalTogSelected != select)
|
||||||
btn.Selected = select;
|
btn.InternalTogSelected = select;
|
||||||
if (select) _current = btn;
|
if (select) _current = btn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +94,7 @@ public class UXGroup : UIBehaviour
|
|||||||
|
|
||||||
private void ValidateGroup()
|
private void ValidateGroup()
|
||||||
{
|
{
|
||||||
if (_current != null && _current.Selected) return;
|
if (_current != null && _current.InternalTogSelected) return;
|
||||||
|
|
||||||
if (!m_AllowSwitchOff && m_Buttons.Count > 0)
|
if (!m_AllowSwitchOff && m_Buttons.Count > 0)
|
||||||
SetSelected(m_Buttons[0]);
|
SetSelected(m_Buttons[0]);
|
||||||
@ -102,7 +103,7 @@ public class UXGroup : UIBehaviour
|
|||||||
public bool AnyOtherSelected(UXButton exclude)
|
public bool AnyOtherSelected(UXButton exclude)
|
||||||
{
|
{
|
||||||
foreach (var btn in m_Buttons)
|
foreach (var btn in m_Buttons)
|
||||||
if (btn != exclude && btn.Selected)
|
if (btn != exclude && btn.InternalTogSelected)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user