commit
7703ca739c
|
@ -12,6 +12,12 @@ namespace UnityEngine.UI
|
||||||
[RequireComponent(typeof(RectTransform))]
|
[RequireComponent(typeof(RectTransform))]
|
||||||
public class ExtensionsToggle : Selectable, IPointerClickHandler, ISubmitHandler, ICanvasElement
|
public class ExtensionsToggle : Selectable, IPointerClickHandler, ISubmitHandler, ICanvasElement
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Variable to identify this script, can be int, string or whatever
|
||||||
|
/// </summary>
|
||||||
|
//public int UniqueID;
|
||||||
|
//public string UniqueID;
|
||||||
|
|
||||||
public enum ToggleTransition
|
public enum ToggleTransition
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
@ -22,6 +28,10 @@ namespace UnityEngine.UI
|
||||||
public class ToggleEvent : UnityEvent<bool>
|
public class ToggleEvent : UnityEvent<bool>
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class ToggleEventObject : UnityEvent<ExtensionsToggle>
|
||||||
|
{ }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Transition type.
|
/// Transition type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -57,6 +67,12 @@ namespace UnityEngine.UI
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ToggleEvent onValueChanged = new ToggleEvent();
|
public ToggleEvent onValueChanged = new ToggleEvent();
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Allow for delegate-based subscriptions for faster events than 'eventReceiver', and allowing for multiple receivers.
|
||||||
|
/// </summary>
|
||||||
|
public ToggleEventObject onValueChangedOn = new ToggleEventObject();
|
||||||
|
|
||||||
// Whether the toggle is on
|
// Whether the toggle is on
|
||||||
[FormerlySerializedAs("m_IsActive")]
|
[FormerlySerializedAs("m_IsActive")]
|
||||||
[Tooltip("Is the toggle currently on or off?")]
|
[Tooltip("Is the toggle currently on or off?")]
|
||||||
|
@ -84,7 +100,11 @@ namespace UnityEngine.UI
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
if (executing == CanvasUpdate.Prelayout)
|
if (executing == CanvasUpdate.Prelayout)
|
||||||
|
{
|
||||||
onValueChanged.Invoke(m_IsOn);
|
onValueChanged.Invoke(m_IsOn);
|
||||||
|
if(m_IsOn)
|
||||||
|
onValueChangedOn.Invoke(this);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +207,11 @@ namespace UnityEngine.UI
|
||||||
// It's up to the user to ignore a selection being set to the same value it already was, if desired.
|
// It's up to the user to ignore a selection being set to the same value it already was, if desired.
|
||||||
PlayEffect(toggleTransition == ToggleTransition.None);
|
PlayEffect(toggleTransition == ToggleTransition.None);
|
||||||
if (sendCallback)
|
if (sendCallback)
|
||||||
|
{
|
||||||
onValueChanged.Invoke(m_IsOn);
|
onValueChanged.Invoke(m_IsOn);
|
||||||
|
if(m_IsOn)
|
||||||
|
onValueChangedOn.Invoke(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue