Files
Magical-Jumping-Bean/Library/metadata/90/9085046f02f69544eb97fd06b6048fe2
T

340 lines
15 KiB
Plaintext
Raw Normal View History

2019-09-29 19:40:54 -04:00
í=Œ2019.2.3f1þÿÿÿÿÿ’3$øÌuñ옲e+ Í=^7€ÿÿÿÿ€¦€²€Ѐ¦€¦€¦€#¦€+H€3ÿÿÿÿ€1€1€ÿÿÿÿ@Þ€€ Q€j€
H€<ÿÿÿÿ €1€1€ÿÿÿÿ @Þ€€
Q€j€Õ€Iÿÿÿÿ€1€1€ÿÿÿÿÀÞ€€H€j€ÿÿÿÿ€1€1€ÿÿÿÿ@Þ€€Q€j€™€PAssetMetaDataguiddata[0]data[1]data[2]data[3]pathNameoriginalNamelabelsassetStoreRef ÿÿfš†!ë5˜9Ý4QÁóBí7€ÿÿÿÿ€¦€²€
E€ Þ€#€.€,€5a€ Þ€#€.€,€†€r€ Þ€# €.€,
€H€«€ÿÿÿÿ €1€1€ÿÿÿÿ @Þ€€
Q€j€ñ€JÿÿÿÿÀ1€1€ÿÿÿÿ€Þ€€€j€ÿÿÿÿ€\›€ÿÿÿÿ€H€rÿÿÿÿ€1€1€ÿÿÿÿ@Þ€€Q€j€H€wÿÿÿÿ€1€1€ÿÿÿÿ@Þ€€Q€j€H€€ÿÿÿÿ€1€1€ÿÿÿÿ@Þ€€Q€j€y€
€ Þ€#!€.€,"€€…ÿÿÿÿ#@1€1€ÿÿÿÿ$Þ€€%.€j€&Õ€“ÿÿÿÿ'€1€1€ÿÿÿÿ(ÀÞ€€)€j€ÿÿÿÿ*€H€›€ÿÿÿÿ+€1€1€ÿÿÿÿ,@Þ€€-Q€j€.y€
€ /Þ€#0€.€,1€ €§2@¾€¶ 3@Þ€#4€.€,5€H€»ÿÿÿÿ6€1€1€ÿÿÿÿ7@Þ€€8Q€j€9H€Æÿÿÿÿ:€1€1€ÿÿÿÿ;@Þ€€<Q€j€=H€Øÿÿÿÿ>€1€1€ÿÿÿÿ?@Þ€€@Q€j€AMonoImporterPPtr<EditorExtension>m_FileIDm_PathIDPPtr<PrefabInstance>m_ExternalObjectsSourceAssetIdentifiertypeassemblynamem_UsedFileIDsm_DefaultReferencesexecutionOrdericonm_UserDatam_AssetBundleNamem_AssetBundleVariantsÿÿ£Gñ×Ü�Z56 :!@iÁJ*�€7€ÿÿÿÿ€¦€²€E€ Þ€€.€€(a€ Þ€€.€€†€r€ Þ€ €.€
€H€«€ÿÿÿÿ €1€1€ÿÿÿÿ @Þ€€
Q€j€H€ê€ÿÿÿÿ€1€1€ÿÿÿÿ@Þ€€Q€j€ñ€=ÿÿÿÿ€1€1€ÿÿÿÿ€Þ€€€j€ÿÿÿÿ€H€›€ÿÿÿÿ€1€1€ÿÿÿÿ@Þ€€Q€j€y€
€ Þ€€.€€y€Q Þ€€.€ €Þ€X!H€iÿÿÿÿ"€1€1€ÿÿÿÿ#@Þ€€$Q€j€%H€uÿÿÿÿ&€1€1€ÿÿÿÿ'@Þ€€(Q€j€)PPtr<EditorExtension>m_FileIDm_PathIDPPtr<PrefabInstance>m_DefaultReferencesm_Iconm_ExecutionOrderm_ClassNamem_Namespace\`\ày¯À¼) X@ö oYD¾yß`k@ø.1Packages/com.unity.ugui/Runtime/UI/Core/Toggle.csày¯ToggleO)using System;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.Serialization;
namespace UnityEngine.UI
{
/// <summary>
/// A standard toggle that has an on / off state.
/// </summary>
/// <remarks>
/// The toggle component is a Selectable that controls a child graphic which displays the on / off state.
/// When a toggle event occurs a callback is sent to any registered listeners of UI.Toggle._onValueChanged.
/// </remarks>
[AddComponentMenu("UI/Toggle", 31)]
[RequireComponent(typeof(RectTransform))]
public class Toggle : Selectable, IPointerClickHandler, ISubmitHandler, ICanvasElement
{
/// <summary>
/// Display settings for when a toggle is activated or deactivated.
/// </summary>
public enum ToggleTransition
{
/// <summary>
/// Show / hide the toggle instantly
/// </summary>
None,
/// <summary>
/// Fade the toggle in / out smoothly.
/// </summary>
Fade
}
[Serializable]
/// <summary>
/// UnityEvent callback for when a toggle is toggled.
/// </summary>
public class ToggleEvent : UnityEvent<bool>
{}
/// <summary>
/// Transition mode for the toggle.
/// </summary>
public ToggleTransition toggleTransition = ToggleTransition.Fade;
/// <summary>
/// Graphic the toggle should be working with.
/// </summary>
public Graphic graphic;
[SerializeField]
private ToggleGroup m_Group;
/// <summary>
/// Group the toggle belongs to.
/// </summary>
public ToggleGroup group
{
get { return m_Group; }
set
{
m_Group = value;
SetToggleGroup(m_Group, true);
PlayEffect(true);
}
}
/// <summary>
/// Allow for delegate-based subscriptions for faster events than 'eventReceiver', and allowing for multiple receivers.
/// </summary>
/// <example>
/// <code>
/// //Attach this script to a Toggle GameObject. To do this, go to Create>UI>Toggle.
/// //Set your own Text in the Inspector window
///
/// using UnityEngine;
/// using UnityEngine.UI;
///
/// public class Example : MonoBehaviour
/// {
/// Toggle m_Toggle;
/// public Text m_Text;
///
/// void Start()
/// {
/// //Fetch the Toggle GameObject
/// m_Toggle = GetComponent<Toggle>();
/// //Add listener for when the state of the Toggle changes, to take action
/// m_Toggle.onValueChanged.AddListener(delegate {
/// ToggleValueChanged(m_Toggle);
/// });
///
/// //Initialise the Text to say the first state of the Toggle
/// m_Text.text = "First Value : " + m_Toggle.isOn;
/// }
///
/// //Output the new state of the Toggle into Text
/// void ToggleValueChanged(Toggle change)
/// {
/// m_Text.text = "New Value : " + m_Toggle.isOn;
/// }
/// }
/// </code>
/// </example>
public ToggleEvent onValueChanged = new ToggleEvent();
// Whether the toggle is on
[Tooltip("Is the toggle currently on or off?")]
[SerializeField]
private bool m_IsOn;
protected Toggle()
{}
#if UNITY_EDITOR
protected override void OnValidate()
{
base.OnValidate();
if (!UnityEditor.PrefabUtility.IsPartOfPrefabAsset(this) && !Application.isPlaying)
CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild(this);
}
#endif // if UNITY_EDITOR
public virtual void Rebuild(CanvasUpdate executing)
{
#if UNITY_EDITOR
if (executing == CanvasUpdate.Prelayout)
onValueChanged.Invoke(m_IsOn);
#endif
}
public virtual void LayoutComplete()
{}
public virtual void GraphicUpdateComplete()
{}
protected override void OnDestroy()
{
if (m_Group != null)
m_Group.EnsureValidState();
base.OnDestroy();
}
protected override void OnEnable()
{
base.OnEnable();
SetToggleGroup(m_Group, false);
PlayEffect(true);
}
protected override void OnDisable()
{
SetToggleGroup(null, false);
base.OnDisable();
}
protected override void OnDidApplyAnimationProperties()
{
// Check if isOn has been changed by the animation.
// Unfortunately there is no way to check if we don�t have a graphic.
if (graphic != null)
{
bool oldValue = !Mathf.Approximately(graphic.canvasRenderer.GetColor().a, 0);
if (m_IsOn != oldValue)
{
m_IsOn = oldValue;
Set(!oldValue);
}
}
base.OnDidApplyAnimationProperties();
}
private void SetToggleGroup(ToggleGroup newGroup, bool setMemberValue)
{
// Sometimes IsActive returns false in OnDisable so don't check for it.
// Rather remove the toggle too often than too little.
if (m_Group != null)
m_Group.UnregisterToggle(this);
// At runtime the group variable should be set but not when calling this method from OnEnable or OnDisable.
// That's why we use the setMemberValue parameter.
if (setMemberValue)
m_Group = newGroup;
// Only register to the new group if this Toggle is active.
if (newGroup != null && IsActive())
newGroup.RegisterToggle(this);
// If we are in a new group, and this toggle is on, notify group.
// Note: Don't refer to m_Group here as it's not guaranteed to have been set.
if (newGroup != null && isOn && IsActive())
newGroup.NotifyToggleOn(this);
}
/// <summary>
/// Whether the toggle is currently active.
/// </summary>
/// <example>
/// <code>
/// /Attach this script to a Toggle GameObject. To do this, go to Create>UI>Toggle.
/// //Set your own Text in the Inspector window
///
/// using UnityEngine;
/// using UnityEngine.UI;
///
/// public class Example : MonoBehaviour
/// {
/// Toggle m_Toggle;
/// public Text m_Text;
///
/// void Start()
/// {
/// //Fetch the Toggle GameObject
/// m_Toggle = GetComponent<Toggle>();
/// //Add listener for when the state of the Toggle changes, and output the state
/// m_Toggle.onValueChanged.AddListener(delegate {
/// ToggleValueChanged(m_Toggle);
/// });
///
/// //Initialize the Text to say whether the Toggle is in a positive or negative state
/// m_Text.text = "Toggle is : " + m_Toggle.isOn;
/// }
///
/// //Output the new state of the Toggle into Text when the user uses the Toggle
/// void ToggleValueChanged(Toggle change)
/// {
/// m_Text.text = "Toggle is : " + m_Toggle.isOn;
/// }
/// }
/// </code>
/// </example>
public bool isOn
{
get { return m_IsOn; }
set
{
Set(value);
}
}
/// <summary>
/// Set isOn without invoking onValueChanged callback.
/// </summary>
/// <param name="value">New Value for isOn.</param>
public void SetIsOnWithoutNotify(bool value)
{
Set(value, false);
}
void Set(bool value, bool sendCallback = true)
{
if (m_IsOn == value)
return;
// if we are in a group and set to true, do group logic
m_IsOn = value;
if (m_Group != null && IsActive())
{
if (m_IsOn || (!m_Group.AnyTogglesOn() && !m_Group.allowSwitchOff))
{
m_IsOn = true;
m_Group.NotifyToggleOn(this, sendCallback);
}
}
// Always send event when toggle is clicked, even if value didn't change
// due to already active toggle in a toggle group being clicked.
// Controls like Dropdown rely on this.
// 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);
if (sendCallback)
{
UISystemProfilerApi.AddMarker("Toggle.value", this);
onValueChanged.Invoke(m_IsOn);
}
}
/// <summary>
/// Play the appropriate effect.
/// </summary>
private void PlayEffect(bool instant)
{
if (graphic == null)
return;
#if UNITY_EDITOR
if (!Application.isPlaying)
graphic.canvasRenderer.SetAlpha(m_IsOn ? 1f : 0f);
else
#endif
graphic.CrossFadeAlpha(m_IsOn ? 1f : 0f, instant ? 0f : 0.1f, true);
}
/// <summary>
/// Assume the correct visual state.
/// </summary>
protected override void Start()
{
PlayEffect(true);
}
private void InternalToggle()
{
if (!IsActive() || !IsInteractable())
return;
isOn = !isOn;
}
/// <summary>
/// React to clicks.
/// </summary>
public virtual void OnPointerClick(PointerEventData eventData)
{
if (eventData.button != PointerEventData.InputButton.Left)
return;
InternalToggle();
}
public virtual void OnSubmit(BaseEventData eventData)
{
InternalToggle();