diff options
Diffstat (limited to 'Assets/uGUI-2017.1/UnityEngine.UI')
6 files changed, 50 insertions, 17 deletions
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/BaseEventData.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/BaseEventData.cs index ecc94aa..f353314 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/BaseEventData.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/BaseEventData.cs @@ -36,7 +36,7 @@ namespace UnityEngine.EventSystems public GameObject selectedObject { get { return m_EventSystem.currentSelectedGameObject; } - set { m_EventSystem.SetSelectedGameObject(value, this); } + set { m_EventSystem.SetSelectedGameObject(value, this); } // �ᷢ��һ��selecthandler�¼� } } } diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Button.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Button.cs index 8641b05..d0c9ae3 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Button.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Button.cs @@ -9,7 +9,10 @@ namespace UnityEngine.UI { // Button that's meant to work with mouse or touch-based devices. [AddComponentMenu("UI/Button", 30)] - public class Button : Selectable, IPointerClickHandler, ISubmitHandler + public class Button + : Selectable + , IPointerClickHandler // �����\���� + , ISubmitHandler // Input>Submit�����������ֱ�������ij���������� { [Serializable] public class ButtonClickedEvent : UnityEvent {} @@ -28,6 +31,7 @@ namespace UnityEngine.UI set { m_OnClick = value; } } + // ���ص� private void Press() { if (!IsActive() || !IsInteractable()) @@ -48,6 +52,8 @@ namespace UnityEngine.UI public virtual void OnSubmit(BaseEventData eventData) { + LogHelper.Log("OnSubmit() " + gameObject.name); + Press(); // if we get set disabled during the press diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Navigation.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Navigation.cs index 8dce1d5..98e77f9 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Navigation.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Navigation.cs @@ -14,11 +14,11 @@ namespace UnityEngine.UI [Flags] public enum Mode { - None = 0, // No navigation - Horizontal = 1, // Automatic horizontal navigation - Vertical = 2, // Automatic vertical navigation - Automatic = 3, // Automatic navigation in both dimensions - Explicit = 4, // Explicitly specified only + None = 0, // 0 No navigation + Horizontal = 1, // 1 Automatic horizontal navigation + Vertical = 2, // 10 Automatic vertical navigation + Automatic = 3, // 11 Automatic navigation in both dimensions + Explicit = 4, // Explicitly specified only } // Which method of navigation will be used. diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Selectable.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Selectable.cs index c0cda18..9cc6178 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Selectable.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Selectable.cs @@ -13,13 +13,14 @@ namespace UnityEngine.UI public class Selectable : UIBehaviour, - IMoveHandler, - IPointerDownHandler, IPointerUpHandler, - IPointerEnterHandler, IPointerExitHandler, - ISelectHandler, IDeselectHandler + IMoveHandler, // Input>Horizontal\Vertical�ƶ�ʱ�յ������Ϣ + IPointerDownHandler, IPointerUpHandler, // ���click + IPointerEnterHandler, IPointerExitHandler, // ��ͣhover + ISelectHandler, IDeselectHandler // navigation��ý���ʱ�յ������Ϣ { // Selection state + // ��ǰ�����е�Selectable��� // List of all the selectable objects currently active in the scene private static List<Selectable> s_List = new List<Selectable>(); public static List<Selectable> allSelectables { get { return s_List; } } @@ -349,7 +350,7 @@ namespace UnityEngine.UI Vector3 pos = transform.TransformPoint(GetPointOnRectEdge(transform as RectTransform, localDir)); float maxScore = Mathf.NegativeInfinity; Selectable bestPick = null; - for (int i = 0; i < s_List.Count; ++i) + for (int i = 0; i < s_List.Count; ++i) // ������ǰ�����е�����selectable��� { Selectable sel = s_List[i]; @@ -410,7 +411,7 @@ namespace UnityEngine.UI void Navigate(AxisEventData eventData, Selectable sel) { if (sel != null && sel.IsActive()) - eventData.selectedObject = sel.gameObject; + eventData.selectedObject = sel.gameObject; // �ᷢ��һ��selectHandler�¼� } // Find the selectable object to the left of this one. @@ -469,12 +470,15 @@ namespace UnityEngine.UI return null; } + // input>horizontal\vertical��������¼��� public virtual void OnMove(AxisEventData eventData) { + LogHelper.Log("OnMove() " + gameObject.name ); + switch (eventData.moveDir) { case MoveDirection.Right: - Navigate(eventData, FindSelectableOnRight()); + Navigate(eventData, FindSelectableOnRight()); // ������һ��selectableObj����һ��OnSelect��Ϣ break; case MoveDirection.Up: @@ -496,6 +500,7 @@ namespace UnityEngine.UI if (m_TargetGraphic == null) return; + // ��һ��Э����tween���� m_TargetGraphic.CrossFadeColor(targetColor, instant ? 0f : m_Colors.fadeDuration, true, true); } @@ -512,6 +517,8 @@ namespace UnityEngine.UI if (transition != Transition.Animation || animator == null || !animator.isActiveAndEnabled || !animator.hasBoundPlayables || string.IsNullOrEmpty(triggername)) return; + LogHelper.Log("trigger animation"); + animator.ResetTrigger(m_AnimationTriggers.normalTrigger); animator.ResetTrigger(m_AnimationTriggers.pressedTrigger); animator.ResetTrigger(m_AnimationTriggers.highlightedTrigger); @@ -578,6 +585,7 @@ namespace UnityEngine.UI m_CurrentSelectionState = SelectionState.Normal; } + // ����״̬���Ŷ��� // Change the button to the correct state private void EvaluateAndTransitionToSelectionState(BaseEventData eventData) { @@ -598,12 +606,14 @@ namespace UnityEngine.UI public virtual void OnPointerDown(PointerEventData eventData) { + LogHelper.Log("OnPointerDown() "+ gameObject.name); + if (eventData.button != PointerEventData.InputButton.Left) return; // Selection tracking if (IsInteractable() && navigation.mode != Navigation.Mode.None && EventSystem.current != null) - EventSystem.current.SetSelectedGameObject(gameObject, eventData); + EventSystem.current.SetSelectedGameObject(gameObject, eventData); // ѡ�����UI��� isPointerDown = true; EvaluateAndTransitionToSelectionState(eventData); @@ -611,6 +621,8 @@ namespace UnityEngine.UI public virtual void OnPointerUp(PointerEventData eventData) { + LogHelper.Log("OnPointerUp() " + gameObject.name); + if (eventData.button != PointerEventData.InputButton.Left) return; @@ -620,24 +632,31 @@ namespace UnityEngine.UI public virtual void OnPointerEnter(PointerEventData eventData) { + LogHelper.Log("OnPointerEnter() " + gameObject.name); + isPointerInside = true; EvaluateAndTransitionToSelectionState(eventData); } public virtual void OnPointerExit(PointerEventData eventData) { + LogHelper.Log("OnPointerExit() " + gameObject.name); + isPointerInside = false; EvaluateAndTransitionToSelectionState(eventData); } + // ��ѡ�� public virtual void OnSelect(BaseEventData eventData) { + LogHelper.Log("OnSelect() " + gameObject.name); hasSelection = true; EvaluateAndTransitionToSelectionState(eventData); } public virtual void OnDeselect(BaseEventData eventData) { + LogHelper.Log("OnDeselect() " + gameObject.name); hasSelection = false; EvaluateAndTransitionToSelectionState(eventData); } diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Slider.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Slider.cs index ce8f4bb..4e80fb3 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Slider.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Slider.cs @@ -6,7 +6,11 @@ namespace UnityEngine.UI { [AddComponentMenu("UI/Slider", 33)] [RequireComponent(typeof(RectTransform))] - public class Slider : Selectable, IDragHandler, IInitializePotentialDragHandler, ICanvasElement + public class Slider + : Selectable + , IDragHandler + , IInitializePotentialDragHandler + , ICanvasElement // �༭���²Ż��õ� { public enum Direction { diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Toggle.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Toggle.cs index 5dc9275..8dc4c82 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Toggle.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Toggle.cs @@ -10,7 +10,11 @@ namespace UnityEngine.UI /// </summary> [AddComponentMenu("UI/Toggle", 31)] [RequireComponent(typeof(RectTransform))] - public class Toggle : Selectable, IPointerClickHandler, ISubmitHandler, ICanvasElement + public class Toggle + : Selectable + , IPointerClickHandler + , ISubmitHandler + , ICanvasElement // 编辑器下用到 { public enum ToggleTransition { |