From 00dae1bd426d892dff73a50f1c505afd1ac00a90 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 8 Oct 2020 09:50:33 +0800 Subject: +init --- Assets/uGUI-2017.1/UnityEngine.UI/EventSystem.meta | 10 + .../UnityEngine.UI/EventSystem/EventData.meta | 10 + .../EventSystem/EventData/AxisEventData.cs | 15 + .../EventSystem/EventData/AxisEventData.cs.meta | 13 + .../EventSystem/EventData/BaseEventData.cs | 42 + .../EventSystem/EventData/BaseEventData.cs.meta | 13 + .../EventSystem/EventData/PointerEventData.cs | 138 ++ .../EventSystem/EventData/PointerEventData.cs.meta | 13 + .../UnityEngine.UI/EventSystem/EventHandle.cs | 11 + .../UnityEngine.UI/EventSystem/EventHandle.cs.meta | 13 + .../UnityEngine.UI/EventSystem/EventInterfaces.cs | 91 + .../EventSystem/EventInterfaces.cs.meta | 13 + .../UnityEngine.UI/EventSystem/EventSystem.cs | 313 +++ .../UnityEngine.UI/EventSystem/EventSystem.cs.meta | 13 + .../UnityEngine.UI/EventSystem/EventTrigger.cs | 156 ++ .../EventSystem/EventTrigger.cs.meta | 13 + .../UnityEngine.UI/EventSystem/EventTriggerType.cs | 29 + .../EventSystem/EventTriggerType.cs.meta | 13 + .../UnityEngine.UI/EventSystem/ExecuteEvents.cs | 360 +++ .../EventSystem/ExecuteEvents.cs.meta | 13 + .../UnityEngine.UI/EventSystem/InputModules.meta | 10 + .../EventSystem/InputModules/BaseInput.cs | 77 + .../EventSystem/InputModules/BaseInput.cs.meta | 13 + .../EventSystem/InputModules/BaseInputModule.cs | 231 ++ .../InputModules/BaseInputModule.cs.meta | 13 + .../EventSystem/InputModules/PointerInputModule.cs | 328 +++ .../InputModules/PointerInputModule.cs.meta | 13 + .../InputModules/StandaloneInputModule.cs | 588 +++++ .../InputModules/StandaloneInputModule.cs.meta | 13 + .../EventSystem/InputModules/TouchInputModule.cs | 260 ++ .../InputModules/TouchInputModule.cs.meta | 13 + .../UnityEngine.UI/EventSystem/MoveDirection.cs | 11 + .../EventSystem/MoveDirection.cs.meta | 13 + .../UnityEngine.UI/EventSystem/RaycastResult.cs | 64 + .../EventSystem/RaycastResult.cs.meta | 13 + .../UnityEngine.UI/EventSystem/RaycasterManager.cs | 29 + .../EventSystem/RaycasterManager.cs.meta | 13 + .../UnityEngine.UI/EventSystem/Raycasters.meta | 10 + .../EventSystem/Raycasters/BaseRaycaster.cs | 47 + .../EventSystem/Raycasters/BaseRaycaster.cs.meta | 13 + .../EventSystem/Raycasters/Physics2DRaycaster.cs | 53 + .../Raycasters/Physics2DRaycaster.cs.meta | 13 + .../EventSystem/Raycasters/PhysicsRaycaster.cs | 114 + .../Raycasters/PhysicsRaycaster.cs.meta | 13 + .../UnityEngine.UI/EventSystem/UIBehaviour.cs | 59 + .../UnityEngine.UI/EventSystem/UIBehaviour.cs.meta | 13 + Assets/uGUI-2017.1/UnityEngine.UI/UI.meta | 10 + .../uGUI-2017.1/UnityEngine.UI/UI/Animation.meta | 10 + .../UnityEngine.UI/UI/Animation/CoroutineTween.cs | 244 ++ .../UI/Animation/CoroutineTween.cs.meta | 13 + Assets/uGUI-2017.1/UnityEngine.UI/UI/Core.meta | 10 + .../UnityEngine.UI/UI/Core/AnimationTriggers.cs | 36 + .../UI/Core/AnimationTriggers.cs.meta | 13 + .../uGUI-2017.1/UnityEngine.UI/UI/Core/Button.cs | 75 + .../UnityEngine.UI/UI/Core/Button.cs.meta | 13 + .../UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs | 275 +++ .../UI/Core/CanvasUpdateRegistry.cs.meta | 13 + .../UnityEngine.UI/UI/Core/ColorBlock.cs | 91 + .../UnityEngine.UI/UI/Core/ColorBlock.cs.meta | 13 + .../UnityEngine.UI/UI/Core/Culling.meta | 10 + .../UI/Core/Culling/ClipperRegistry.cs | 50 + .../UI/Core/Culling/ClipperRegistry.cs.meta | 13 + .../UnityEngine.UI/UI/Core/Culling/Clipping.cs | 43 + .../UI/Core/Culling/Clipping.cs.meta | 13 + .../UnityEngine.UI/UI/Core/Culling/IClipRegion.cs | 16 + .../UI/Core/Culling/IClipRegion.cs.meta | 13 + .../UI/Core/Culling/RectangularVertexClipper.cs | 21 + .../Core/Culling/RectangularVertexClipper.cs.meta | 13 + .../UnityEngine.UI/UI/Core/DefaultControls.cs | 581 +++++ .../UnityEngine.UI/UI/Core/DefaultControls.cs.meta | 13 + .../uGUI-2017.1/UnityEngine.UI/UI/Core/Dropdown.cs | 649 +++++ .../UnityEngine.UI/UI/Core/Dropdown.cs.meta | 13 + .../uGUI-2017.1/UnityEngine.UI/UI/Core/FontData.cs | 158 ++ .../UnityEngine.UI/UI/Core/FontData.cs.meta | 13 + .../UnityEngine.UI/UI/Core/FontUpdateTracker.cs | 67 + .../UI/Core/FontUpdateTracker.cs.meta | 13 + .../uGUI-2017.1/UnityEngine.UI/UI/Core/Graphic.cs | 654 ++++++ .../UnityEngine.UI/UI/Core/Graphic.cs.meta | 13 + .../UnityEngine.UI/UI/Core/GraphicRaycaster.cs | 287 +++ .../UI/Core/GraphicRaycaster.cs.meta | 13 + .../UI/Core/GraphicRebuildTracker.cs | 38 + .../UI/Core/GraphicRebuildTracker.cs.meta | 13 + .../UnityEngine.UI/UI/Core/GraphicRegistry.cs | 76 + .../UnityEngine.UI/UI/Core/GraphicRegistry.cs.meta | 13 + .../UI/Core/IGraphicEnabledDisabled.cs | 10 + .../UI/Core/IGraphicEnabledDisabled.cs.meta | 13 + Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/IMask.cs | 11 + .../UnityEngine.UI/UI/Core/IMask.cs.meta | 13 + .../UnityEngine.UI/UI/Core/IMaskable.cs | 9 + .../UnityEngine.UI/UI/Core/IMaskable.cs.meta | 13 + Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Image.cs | 1165 +++++++++ .../UnityEngine.UI/UI/Core/Image.cs.meta | 13 + .../UnityEngine.UI/UI/Core/InputField.cs | 2483 ++++++++++++++++++++ .../UnityEngine.UI/UI/Core/InputField.cs.meta | 13 + .../uGUI-2017.1/UnityEngine.UI/UI/Core/Layout.meta | 10 + .../UI/Core/Layout/AspectRatioFitter.cs | 145 ++ .../UI/Core/Layout/AspectRatioFitter.cs.meta | 13 + .../UnityEngine.UI/UI/Core/Layout/CanvasScaler.cs | 241 ++ .../UI/Core/Layout/CanvasScaler.cs.meta | 13 + .../UI/Core/Layout/ContentSizeFitter.cs | 103 + .../UI/Core/Layout/ContentSizeFitter.cs.meta | 13 + .../UI/Core/Layout/GridLayoutGroup.cs | 207 ++ .../UI/Core/Layout/GridLayoutGroup.cs.meta | 13 + .../UI/Core/Layout/HorizontalLayoutGroup.cs | 30 + .../UI/Core/Layout/HorizontalLayoutGroup.cs.meta | 13 + .../Core/Layout/HorizontalOrVerticalLayoutGroup.cs | 169 ++ .../Layout/HorizontalOrVerticalLayoutGroup.cs.meta | 13 + .../UI/Core/Layout/ILayoutElement.cs | 48 + .../UI/Core/Layout/ILayoutElement.cs.meta | 13 + .../UnityEngine.UI/UI/Core/Layout/LayoutElement.cs | 78 + .../UI/Core/Layout/LayoutElement.cs.meta | 13 + .../UnityEngine.UI/UI/Core/Layout/LayoutGroup.cs | 234 ++ .../UI/Core/Layout/LayoutGroup.cs.meta | 13 + .../UI/Core/Layout/LayoutRebuilder.cs | 222 ++ .../UI/Core/Layout/LayoutRebuilder.cs.meta | 13 + .../UnityEngine.UI/UI/Core/Layout/LayoutUtility.cs | 112 + .../UI/Core/Layout/LayoutUtility.cs.meta | 13 + .../UI/Core/Layout/VerticalLayoutGroup.cs | 30 + .../UI/Core/Layout/VerticalLayoutGroup.cs.meta | 13 + Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Mask.cs | 166 ++ .../UnityEngine.UI/UI/Core/Mask.cs.meta | 13 + .../UnityEngine.UI/UI/Core/MaskUtilities.cs | 182 ++ .../UnityEngine.UI/UI/Core/MaskUtilities.cs.meta | 13 + .../UnityEngine.UI/UI/Core/MaskableGraphic.cs | 229 ++ .../UnityEngine.UI/UI/Core/MaskableGraphic.cs.meta | 13 + .../UnityEngine.UI/UI/Core/MaterialModifiers.meta | 10 + .../UI/Core/MaterialModifiers/IMaterialModifier.cs | 7 + .../MaterialModifiers/IMaterialModifier.cs.meta | 13 + Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Misc.cs | 44 + .../UnityEngine.UI/UI/Core/Misc.cs.meta | 13 + .../UnityEngine.UI/UI/Core/Navigation.cs | 74 + .../UnityEngine.UI/UI/Core/Navigation.cs.meta | 13 + .../uGUI-2017.1/UnityEngine.UI/UI/Core/RawImage.cs | 121 + .../UnityEngine.UI/UI/Core/RawImage.cs.meta | 13 + .../UnityEngine.UI/UI/Core/RectMask2D.cs | 173 ++ .../UnityEngine.UI/UI/Core/RectMask2D.cs.meta | 13 + .../UnityEngine.UI/UI/Core/ScrollRect.cs | 864 +++++++ .../UnityEngine.UI/UI/Core/ScrollRect.cs.meta | 13 + .../UnityEngine.UI/UI/Core/Scrollbar.cs | 417 ++++ .../UnityEngine.UI/UI/Core/Scrollbar.cs.meta | 13 + .../UnityEngine.UI/UI/Core/Selectable.cs | 648 +++++ .../UnityEngine.UI/UI/Core/Selectable.cs.meta | 13 + .../UnityEngine.UI/UI/Core/SetPropertyUtility.cs | 36 + .../UI/Core/SetPropertyUtility.cs.meta | 13 + .../uGUI-2017.1/UnityEngine.UI/UI/Core/Slider.cs | 442 ++++ .../UnityEngine.UI/UI/Core/Slider.cs.meta | 13 + .../UI/Core/SpecializedCollections.meta | 10 + .../UI/Core/SpecializedCollections/IndexedSet.cs | 152 ++ .../Core/SpecializedCollections/IndexedSet.cs.meta | 13 + .../UnityEngine.UI/UI/Core/SpriteState.cs | 33 + .../UnityEngine.UI/UI/Core/SpriteState.cs.meta | 13 + .../UnityEngine.UI/UI/Core/StencilMaterial.cs | 169 ++ .../UnityEngine.UI/UI/Core/StencilMaterial.cs.meta | 13 + Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Text.cs | 571 +++++ .../UnityEngine.UI/UI/Core/Text.cs.meta | 13 + .../uGUI-2017.1/UnityEngine.UI/UI/Core/Toggle.cs | 242 ++ .../UnityEngine.UI/UI/Core/Toggle.cs.meta | 13 + .../UnityEngine.UI/UI/Core/ToggleGroup.cs | 73 + .../UnityEngine.UI/UI/Core/ToggleGroup.cs.meta | 13 + .../UnityEngine.UI/UI/Core/Utility.meta | 10 + .../UnityEngine.UI/UI/Core/Utility/ListPool.cs | 22 + .../UI/Core/Utility/ListPool.cs.meta | 13 + .../UnityEngine.UI/UI/Core/Utility/ObjectPool.cs | 48 + .../UI/Core/Utility/ObjectPool.cs.meta | 13 + .../UI/Core/Utility/ReflectionMethodsCache.cs | 53 + .../UI/Core/Utility/ReflectionMethodsCache.cs.meta | 13 + .../UnityEngine.UI/UI/Core/Utility/VertexHelper.cs | 193 ++ .../UI/Core/Utility/VertexHelper.cs.meta | 13 + .../UnityEngine.UI/UI/Core/VertexModifiers.meta | 10 + .../UI/Core/VertexModifiers/BaseMeshEffect.cs | 73 + .../UI/Core/VertexModifiers/BaseMeshEffect.cs.meta | 13 + .../UI/Core/VertexModifiers/IMeshModifier.cs | 19 + .../UI/Core/VertexModifiers/IMeshModifier.cs.meta | 13 + .../UI/Core/VertexModifiers/Outline.cs | 44 + .../UI/Core/VertexModifiers/Outline.cs.meta | 13 + .../UI/Core/VertexModifiers/PositionAsUV1.cs | 22 + .../UI/Core/VertexModifiers/PositionAsUV1.cs.meta | 13 + .../UI/Core/VertexModifiers/Shadow.cs | 123 + .../UI/Core/VertexModifiers/Shadow.cs.meta | 13 + 179 files changed, 18123 insertions(+) create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/AxisEventData.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/AxisEventData.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/BaseEventData.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/BaseEventData.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/PointerEventData.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/PointerEventData.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventHandle.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventHandle.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventInterfaces.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventInterfaces.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventSystem.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventSystem.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventTrigger.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventTrigger.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventTriggerType.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventTriggerType.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInput.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInput.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInputModule.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInputModule.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/PointerInputModule.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/PointerInputModule.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/StandaloneInputModule.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/StandaloneInputModule.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/TouchInputModule.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/TouchInputModule.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/MoveDirection.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/MoveDirection.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/RaycastResult.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/RaycastResult.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/RaycasterManager.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/RaycasterManager.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/BaseRaycaster.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/BaseRaycaster.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/Physics2DRaycaster.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/Physics2DRaycaster.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/PhysicsRaycaster.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/PhysicsRaycaster.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/UIBehaviour.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/UIBehaviour.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Animation.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Animation/CoroutineTween.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Animation/CoroutineTween.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/AnimationTriggers.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/AnimationTriggers.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Button.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Button.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/ColorBlock.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/ColorBlock.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/ClipperRegistry.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/ClipperRegistry.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/Clipping.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/Clipping.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/IClipRegion.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/IClipRegion.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/RectangularVertexClipper.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/RectangularVertexClipper.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/DefaultControls.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/DefaultControls.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Dropdown.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Dropdown.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/FontData.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/FontData.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/FontUpdateTracker.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/FontUpdateTracker.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Graphic.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Graphic.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/GraphicRaycaster.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/GraphicRaycaster.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/GraphicRebuildTracker.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/GraphicRebuildTracker.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/GraphicRegistry.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/GraphicRegistry.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/IGraphicEnabledDisabled.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/IGraphicEnabledDisabled.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/IMask.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/IMask.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/IMaskable.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/IMaskable.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Image.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Image.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/InputField.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/InputField.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/AspectRatioFitter.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/AspectRatioFitter.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/CanvasScaler.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/CanvasScaler.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/ContentSizeFitter.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/ContentSizeFitter.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/GridLayoutGroup.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/GridLayoutGroup.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/HorizontalLayoutGroup.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/HorizontalLayoutGroup.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/HorizontalOrVerticalLayoutGroup.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/HorizontalOrVerticalLayoutGroup.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/ILayoutElement.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/ILayoutElement.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/LayoutElement.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/LayoutElement.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/LayoutGroup.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/LayoutGroup.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/LayoutRebuilder.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/LayoutRebuilder.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/LayoutUtility.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/LayoutUtility.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/VerticalLayoutGroup.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/VerticalLayoutGroup.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Mask.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Mask.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/MaskUtilities.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/MaskUtilities.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/MaskableGraphic.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/MaskableGraphic.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/MaterialModifiers.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/MaterialModifiers/IMaterialModifier.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/MaterialModifiers/IMaterialModifier.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Misc.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Misc.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Navigation.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Navigation.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/RawImage.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/RawImage.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/RectMask2D.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/RectMask2D.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/ScrollRect.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/ScrollRect.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Scrollbar.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Scrollbar.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Selectable.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Selectable.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/SetPropertyUtility.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/SetPropertyUtility.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Slider.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Slider.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/SpecializedCollections.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/SpecializedCollections/IndexedSet.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/SpecializedCollections/IndexedSet.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/SpriteState.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/SpriteState.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/StencilMaterial.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/StencilMaterial.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Text.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Text.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Toggle.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Toggle.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/ToggleGroup.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/ToggleGroup.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Utility.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Utility/ListPool.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Utility/ListPool.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Utility/ObjectPool.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Utility/ObjectPool.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Utility/ReflectionMethodsCache.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Utility/ReflectionMethodsCache.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Utility/VertexHelper.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Utility/VertexHelper.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/BaseMeshEffect.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/BaseMeshEffect.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/IMeshModifier.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/IMeshModifier.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/Outline.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/Outline.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/PositionAsUV1.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/PositionAsUV1.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/Shadow.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/Shadow.cs.meta (limited to 'Assets/uGUI-2017.1/UnityEngine.UI') diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem.meta new file mode 100644 index 0000000..608a0d2 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 6d4a24f03e32ddb46aa2d88b59098524 +folderAsset: yes +timeCreated: 1602119280 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData.meta new file mode 100644 index 0000000..6a26991 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 2a7965b878e0c3c4abdb68deac365981 +folderAsset: yes +timeCreated: 1602119280 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/AxisEventData.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/AxisEventData.cs new file mode 100644 index 0000000..3278d6d --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/AxisEventData.cs @@ -0,0 +1,15 @@ +namespace UnityEngine.EventSystems +{ + public class AxisEventData : BaseEventData + { + public Vector2 moveVector { get; set; } + public MoveDirection moveDir { get; set; } + + public AxisEventData(EventSystem eventSystem) + : base(eventSystem) + { + moveVector = Vector2.zero; + moveDir = MoveDirection.None; + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/AxisEventData.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/AxisEventData.cs.meta new file mode 100644 index 0000000..d770a40 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/AxisEventData.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 068c7c2e61fdac34ebd23b76779526fd +timeCreated: 1602119377 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/BaseEventData.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/BaseEventData.cs new file mode 100644 index 0000000..62e6cb4 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/BaseEventData.cs @@ -0,0 +1,42 @@ +namespace UnityEngine.EventSystems +{ + public abstract class AbstractEventData + { + protected bool m_Used; + + public virtual void Reset() + { + m_Used = false; + } + + public virtual void Use() + { + m_Used = true; + } + + public virtual bool used + { + get { return m_Used; } + } + } + + public class BaseEventData : AbstractEventData + { + private readonly EventSystem m_EventSystem; + public BaseEventData(EventSystem eventSystem) + { + m_EventSystem = eventSystem; + } + + public BaseInputModule currentInputModule + { + get { return m_EventSystem.currentInputModule; } + } + + public GameObject selectedObject + { + get { return m_EventSystem.currentSelectedGameObject; } + set { m_EventSystem.SetSelectedGameObject(value, this); } + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/BaseEventData.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/BaseEventData.cs.meta new file mode 100644 index 0000000..5265b51 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/BaseEventData.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 8249b81d25be82b4388cb41d127fe369 +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/PointerEventData.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/PointerEventData.cs new file mode 100644 index 0000000..9b94e00 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/PointerEventData.cs @@ -0,0 +1,138 @@ +using System; +using System.Text; +using System.Collections.Generic; + +namespace UnityEngine.EventSystems +{ + /// + /// Each touch event creates one of these containing all the relevant information. + /// + public class PointerEventData : BaseEventData + { + public enum InputButton + { + Left = 0, + Right = 1, + Middle = 2 + } + + public enum FramePressState + { + Pressed, + Released, + PressedAndReleased, + NotChanged + } + + public GameObject pointerEnter { get; set; } + + // The object that received OnPointerDown + private GameObject m_PointerPress; + // The object last received OnPointerDown + public GameObject lastPress { get; private set; } + // The object that the press happened on even if it can not handle the press event + public GameObject rawPointerPress { get; set; } + // The object that received OnDrag + public GameObject pointerDrag { get; set; } + + public RaycastResult pointerCurrentRaycast { get; set; } + public RaycastResult pointerPressRaycast { get; set; } + + public List hovered = new List(); + + public bool eligibleForClick { get; set; } + + public int pointerId { get; set; } + + // Current position of the mouse or touch event + public Vector2 position { get; set; } + // Delta since last update + public Vector2 delta { get; set; } + // Position of the press event + public Vector2 pressPosition { get; set; } + // World-space position where a ray cast into the screen hits something + [Obsolete("Use either pointerCurrentRaycast.worldPosition or pointerPressRaycast.worldPosition")] + public Vector3 worldPosition { get; set; } + // World-space normal where a ray cast into the screen hits something + [Obsolete("Use either pointerCurrentRaycast.worldNormal or pointerPressRaycast.worldNormal")] + public Vector3 worldNormal { get; set; } + // The last time a click event was sent out (used for double-clicks) + public float clickTime { get; set; } + // Number of clicks in a row. 2 for a double-click for example. + public int clickCount { get; set; } + + public Vector2 scrollDelta { get; set; } + public bool useDragThreshold { get; set; } + public bool dragging { get; set; } + + public InputButton button { get; set; } + + public PointerEventData(EventSystem eventSystem) : base(eventSystem) + { + eligibleForClick = false; + + pointerId = -1; + position = Vector2.zero; // Current position of the mouse or touch event + delta = Vector2.zero; // Delta since last update + pressPosition = Vector2.zero; // Delta since the event started being tracked + clickTime = 0.0f; // The last time a click event was sent out (used for double-clicks) + clickCount = 0; // Number of clicks in a row. 2 for a double-click for example. + + scrollDelta = Vector2.zero; + useDragThreshold = true; + dragging = false; + button = InputButton.Left; + } + + public bool IsPointerMoving() + { + return delta.sqrMagnitude > 0.0f; + } + + public bool IsScrolling() + { + return scrollDelta.sqrMagnitude > 0.0f; + } + + public Camera enterEventCamera + { + get { return pointerCurrentRaycast.module == null ? null : pointerCurrentRaycast.module.eventCamera; } + } + + public Camera pressEventCamera + { + get { return pointerPressRaycast.module == null ? null : pointerPressRaycast.module.eventCamera; } + } + + public GameObject pointerPress + { + get { return m_PointerPress; } + set + { + if (m_PointerPress == value) + return; + + lastPress = m_PointerPress; + m_PointerPress = value; + } + } + + public override string ToString() + { + var sb = new StringBuilder(); + sb.AppendLine("Position: " + position); + sb.AppendLine("delta: " + delta); + sb.AppendLine("eligibleForClick: " + eligibleForClick); + sb.AppendLine("pointerEnter: " + pointerEnter); + sb.AppendLine("pointerPress: " + pointerPress); + sb.AppendLine("lastPointerPress: " + lastPress); + sb.AppendLine("pointerDrag: " + pointerDrag); + sb.AppendLine("Use Drag Threshold: " + useDragThreshold); + sb.AppendLine("Current Rayast:"); + sb.AppendLine(pointerCurrentRaycast.ToString()); + sb.AppendLine("Press Rayast:"); + sb.AppendLine(pointerPressRaycast.ToString()); + return sb.ToString(); + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/PointerEventData.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/PointerEventData.cs.meta new file mode 100644 index 0000000..866eab8 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/PointerEventData.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 721b5956a0219d74b9aa58b2fd44ffe3 +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventHandle.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventHandle.cs new file mode 100644 index 0000000..977514f --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventHandle.cs @@ -0,0 +1,11 @@ +using System; + +namespace UnityEngine.EventSystems +{ + [Flags] + public enum EventHandle + { + Unused = 0, + Used = 1 + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventHandle.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventHandle.cs.meta new file mode 100644 index 0000000..484a7cd --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventHandle.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 5919f1bb652e12b46a1abbf58653b28c +timeCreated: 1602119378 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventInterfaces.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventInterfaces.cs new file mode 100644 index 0000000..b808e6c --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventInterfaces.cs @@ -0,0 +1,91 @@ +namespace UnityEngine.EventSystems +{ + public interface IEventSystemHandler + { + } + + public interface IPointerEnterHandler : IEventSystemHandler + { + void OnPointerEnter(PointerEventData eventData); + } + + public interface IPointerExitHandler : IEventSystemHandler + { + void OnPointerExit(PointerEventData eventData); + } + + public interface IPointerDownHandler : IEventSystemHandler + { + void OnPointerDown(PointerEventData eventData); + } + + public interface IPointerUpHandler : IEventSystemHandler + { + void OnPointerUp(PointerEventData eventData); + } + + public interface IPointerClickHandler : IEventSystemHandler + { + void OnPointerClick(PointerEventData eventData); + } + + public interface IBeginDragHandler : IEventSystemHandler + { + void OnBeginDrag(PointerEventData eventData); + } + + public interface IInitializePotentialDragHandler : IEventSystemHandler + { + void OnInitializePotentialDrag(PointerEventData eventData); + } + + public interface IDragHandler : IEventSystemHandler + { + void OnDrag(PointerEventData eventData); + } + + public interface IEndDragHandler : IEventSystemHandler + { + void OnEndDrag(PointerEventData eventData); + } + + public interface IDropHandler : IEventSystemHandler + { + void OnDrop(PointerEventData eventData); + } + + public interface IScrollHandler : IEventSystemHandler + { + void OnScroll(PointerEventData eventData); + } + + public interface IUpdateSelectedHandler : IEventSystemHandler + { + void OnUpdateSelected(BaseEventData eventData); + } + + public interface ISelectHandler : IEventSystemHandler + { + void OnSelect(BaseEventData eventData); + } + + public interface IDeselectHandler : IEventSystemHandler + { + void OnDeselect(BaseEventData eventData); + } + + public interface IMoveHandler : IEventSystemHandler + { + void OnMove(AxisEventData eventData); + } + + public interface ISubmitHandler : IEventSystemHandler + { + void OnSubmit(BaseEventData eventData); + } + + public interface ICancelHandler : IEventSystemHandler + { + void OnCancel(BaseEventData eventData); + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventInterfaces.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventInterfaces.cs.meta new file mode 100644 index 0000000..436f77b --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventInterfaces.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 40c86ee97518df241a850e926719dbc2 +timeCreated: 1602119378 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventSystem.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventSystem.cs new file mode 100644 index 0000000..7ddabb8 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventSystem.cs @@ -0,0 +1,313 @@ +using System; +using System.Collections.Generic; +using System.Text; +using UnityEngine; +using UnityEngine.Serialization; + +namespace UnityEngine.EventSystems +{ + [AddComponentMenu("Event/Event System")] + public class EventSystem : UIBehaviour + { + private List m_SystemInputModules = new List(); + + private BaseInputModule m_CurrentInputModule; + + public static EventSystem current { get; set; } + + [SerializeField] + [FormerlySerializedAs("m_Selected")] + private GameObject m_FirstSelected; + + [SerializeField] + private bool m_sendNavigationEvents = true; + + public bool sendNavigationEvents + { + get { return m_sendNavigationEvents; } + set { m_sendNavigationEvents = value; } + } + + [SerializeField] + private int m_DragThreshold = 5; + public int pixelDragThreshold + { + get { return m_DragThreshold; } + set { m_DragThreshold = value; } + } + + private GameObject m_CurrentSelected; + + public BaseInputModule currentInputModule + { + get { return m_CurrentInputModule; } + } + + /// + /// Only one object can be selected at a time. Think: controller-selected button. + /// + public GameObject firstSelectedGameObject + { + get { return m_FirstSelected; } + set { m_FirstSelected = value; } + } + + public GameObject currentSelectedGameObject + { + get { return m_CurrentSelected; } + } + + [Obsolete("lastSelectedGameObject is no longer supported")] + public GameObject lastSelectedGameObject + { + get { return null; } + } + + private bool m_HasFocus = true; + + public bool isFocused + { + get { return m_HasFocus; } + } + + protected EventSystem() + {} + + public void UpdateModules() + { + GetComponents(m_SystemInputModules); + for (int i = m_SystemInputModules.Count - 1; i >= 0; i--) + { + if (m_SystemInputModules[i] && m_SystemInputModules[i].IsActive()) + continue; + + m_SystemInputModules.RemoveAt(i); + } + } + + private bool m_SelectionGuard; + public bool alreadySelecting + { + get { return m_SelectionGuard; } + } + + public void SetSelectedGameObject(GameObject selected, BaseEventData pointer) + { + if (m_SelectionGuard) + { + Debug.LogError("Attempting to select " + selected + "while already selecting an object."); + return; + } + + m_SelectionGuard = true; + if (selected == m_CurrentSelected) + { + m_SelectionGuard = false; + return; + } + + // Debug.Log("Selection: new (" + selected + ") old (" + m_CurrentSelected + ")"); + ExecuteEvents.Execute(m_CurrentSelected, pointer, ExecuteEvents.deselectHandler); + m_CurrentSelected = selected; + ExecuteEvents.Execute(m_CurrentSelected, pointer, ExecuteEvents.selectHandler); + m_SelectionGuard = false; + } + + private BaseEventData m_DummyData; + private BaseEventData baseEventDataCache + { + get + { + if (m_DummyData == null) + m_DummyData = new BaseEventData(this); + + return m_DummyData; + } + } + + public void SetSelectedGameObject(GameObject selected) + { + SetSelectedGameObject(selected, baseEventDataCache); + } + + private static int RaycastComparer(RaycastResult lhs, RaycastResult rhs) + { + if (lhs.module != rhs.module) + { + var lhsEventCamera = lhs.module.eventCamera; + var rhsEventCamera = rhs.module.eventCamera; + if (lhsEventCamera != null && rhsEventCamera != null && lhsEventCamera.depth != rhsEventCamera.depth) + { + // need to reverse the standard compareTo + if (lhsEventCamera.depth < rhsEventCamera.depth) + return 1; + if (lhsEventCamera.depth == rhsEventCamera.depth) + return 0; + + return -1; + } + + if (lhs.module.sortOrderPriority != rhs.module.sortOrderPriority) + return rhs.module.sortOrderPriority.CompareTo(lhs.module.sortOrderPriority); + + if (lhs.module.renderOrderPriority != rhs.module.renderOrderPriority) + return rhs.module.renderOrderPriority.CompareTo(lhs.module.renderOrderPriority); + } + + if (lhs.sortingLayer != rhs.sortingLayer) + { + // Uses the layer value to properly compare the relative order of the layers. + var rid = SortingLayer.GetLayerValueFromID(rhs.sortingLayer); + var lid = SortingLayer.GetLayerValueFromID(lhs.sortingLayer); + return rid.CompareTo(lid); + } + + + if (lhs.sortingOrder != rhs.sortingOrder) + return rhs.sortingOrder.CompareTo(lhs.sortingOrder); + + if (lhs.depth != rhs.depth) + return rhs.depth.CompareTo(lhs.depth); + + if (lhs.distance != rhs.distance) + return lhs.distance.CompareTo(rhs.distance); + + return lhs.index.CompareTo(rhs.index); + } + + private static readonly Comparison s_RaycastComparer = RaycastComparer; + + public void RaycastAll(PointerEventData eventData, List raycastResults) + { + raycastResults.Clear(); + var modules = RaycasterManager.GetRaycasters(); + for (int i = 0; i < modules.Count; ++i) + { + var module = modules[i]; + if (module == null || !module.IsActive()) + continue; + + module.Raycast(eventData, raycastResults); + } + + raycastResults.Sort(s_RaycastComparer); + } + + public bool IsPointerOverGameObject() + { + return IsPointerOverGameObject(PointerInputModule.kMouseLeftId); + } + + public bool IsPointerOverGameObject(int pointerId) + { + if (m_CurrentInputModule == null) + return false; + + return m_CurrentInputModule.IsPointerOverGameObject(pointerId); + } + + protected override void OnEnable() + { + base.OnEnable(); + if (EventSystem.current == null) + EventSystem.current = this; +#if UNITY_EDITOR + else + { + Debug.LogWarning("Multiple EventSystems in scene... this is not supported"); + } +#endif + } + + protected override void OnDisable() + { + if (m_CurrentInputModule != null) + { + m_CurrentInputModule.DeactivateModule(); + m_CurrentInputModule = null; + } + + if (EventSystem.current == this) + EventSystem.current = null; + + base.OnDisable(); + } + + private void TickModules() + { + for (var i = 0; i < m_SystemInputModules.Count; i++) + { + if (m_SystemInputModules[i] != null) + m_SystemInputModules[i].UpdateModule(); + } + } + + protected virtual void OnApplicationFocus(bool hasFocus) + { + m_HasFocus = hasFocus; + } + + protected virtual void Update() + { + if (current != this) + return; + TickModules(); + + bool changedModule = false; + for (var i = 0; i < m_SystemInputModules.Count; i++) + { + var module = m_SystemInputModules[i]; + if (module.IsModuleSupported() && module.ShouldActivateModule()) + { + if (m_CurrentInputModule != module) + { + ChangeEventModule(module); + changedModule = true; + } + break; + } + } + + // no event module set... set the first valid one... + if (m_CurrentInputModule == null) + { + for (var i = 0; i < m_SystemInputModules.Count; i++) + { + var module = m_SystemInputModules[i]; + if (module.IsModuleSupported()) + { + ChangeEventModule(module); + changedModule = true; + break; + } + } + } + + if (!changedModule && m_CurrentInputModule != null) + m_CurrentInputModule.Process(); + } + + private void ChangeEventModule(BaseInputModule module) + { + if (m_CurrentInputModule == module) + return; + + if (m_CurrentInputModule != null) + m_CurrentInputModule.DeactivateModule(); + + if (module != null) + module.ActivateModule(); + m_CurrentInputModule = module; + } + + public override string ToString() + { + var sb = new StringBuilder(); + sb.AppendLine("Selected:" + currentSelectedGameObject); + sb.AppendLine(); + sb.AppendLine(); + sb.AppendLine(m_CurrentInputModule != null ? m_CurrentInputModule.ToString() : "No module"); + return sb.ToString(); + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventSystem.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventSystem.cs.meta new file mode 100644 index 0000000..ad6192d --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventSystem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 47dabc676519a2840ab00d4e00228528 +timeCreated: 1602119378 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventTrigger.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventTrigger.cs new file mode 100644 index 0000000..6f4f179 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventTrigger.cs @@ -0,0 +1,156 @@ +using System; +using System.Collections.Generic; +using UnityEngine.Events; +using UnityEngine.Serialization; + +namespace UnityEngine.EventSystems +{ + [AddComponentMenu("Event/Event Trigger")] + public class EventTrigger : + MonoBehaviour, + IPointerEnterHandler, + IPointerExitHandler, + IPointerDownHandler, + IPointerUpHandler, + IPointerClickHandler, + IInitializePotentialDragHandler, + IBeginDragHandler, + IDragHandler, + IEndDragHandler, + IDropHandler, + IScrollHandler, + IUpdateSelectedHandler, + ISelectHandler, + IDeselectHandler, + IMoveHandler, + ISubmitHandler, + ICancelHandler + { + [Serializable] + public class TriggerEvent : UnityEvent + {} + + [Serializable] + public class Entry + { + public EventTriggerType eventID = EventTriggerType.PointerClick; + public TriggerEvent callback = new TriggerEvent(); + } + + [FormerlySerializedAs("delegates")] + [SerializeField] + private List m_Delegates; + + [Obsolete("Please use triggers instead (UnityUpgradable) -> triggers", true)] + public List delegates; + + protected EventTrigger() + {} + + public List triggers + { + get + { + if (m_Delegates == null) + m_Delegates = new List(); + return m_Delegates; + } + set { m_Delegates = value; } + } + + private void Execute(EventTriggerType id, BaseEventData eventData) + { + for (int i = 0, imax = triggers.Count; i < imax; ++i) + { + var ent = triggers[i]; + if (ent.eventID == id && ent.callback != null) + ent.callback.Invoke(eventData); + } + } + + public virtual void OnPointerEnter(PointerEventData eventData) + { + Execute(EventTriggerType.PointerEnter, eventData); + } + + public virtual void OnPointerExit(PointerEventData eventData) + { + Execute(EventTriggerType.PointerExit, eventData); + } + + public virtual void OnDrag(PointerEventData eventData) + { + Execute(EventTriggerType.Drag, eventData); + } + + public virtual void OnDrop(PointerEventData eventData) + { + Execute(EventTriggerType.Drop, eventData); + } + + public virtual void OnPointerDown(PointerEventData eventData) + { + Execute(EventTriggerType.PointerDown, eventData); + } + + public virtual void OnPointerUp(PointerEventData eventData) + { + Execute(EventTriggerType.PointerUp, eventData); + } + + public virtual void OnPointerClick(PointerEventData eventData) + { + Execute(EventTriggerType.PointerClick, eventData); + } + + public virtual void OnSelect(BaseEventData eventData) + { + Execute(EventTriggerType.Select, eventData); + } + + public virtual void OnDeselect(BaseEventData eventData) + { + Execute(EventTriggerType.Deselect, eventData); + } + + public virtual void OnScroll(PointerEventData eventData) + { + Execute(EventTriggerType.Scroll, eventData); + } + + public virtual void OnMove(AxisEventData eventData) + { + Execute(EventTriggerType.Move, eventData); + } + + public virtual void OnUpdateSelected(BaseEventData eventData) + { + Execute(EventTriggerType.UpdateSelected, eventData); + } + + public virtual void OnInitializePotentialDrag(PointerEventData eventData) + { + Execute(EventTriggerType.InitializePotentialDrag, eventData); + } + + public virtual void OnBeginDrag(PointerEventData eventData) + { + Execute(EventTriggerType.BeginDrag, eventData); + } + + public virtual void OnEndDrag(PointerEventData eventData) + { + Execute(EventTriggerType.EndDrag, eventData); + } + + public virtual void OnSubmit(BaseEventData eventData) + { + Execute(EventTriggerType.Submit, eventData); + } + + public virtual void OnCancel(BaseEventData eventData) + { + Execute(EventTriggerType.Cancel, eventData); + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventTrigger.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventTrigger.cs.meta new file mode 100644 index 0000000..bbb941c --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventTrigger.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 17193886a08901d45ba6c4e9cebb18f6 +timeCreated: 1602119377 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventTriggerType.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventTriggerType.cs new file mode 100644 index 0000000..11c232c --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventTriggerType.cs @@ -0,0 +1,29 @@ +namespace UnityEngine.EventSystems +{ + /// + /// This class is capable of triggering one or more remote functions from a specified event. + /// Usage: Attach it to an object with a collider, or to a GUI Graphic of your choice. + /// NOTE: Doing this will make this object intercept ALL events, and no event bubbling will occur from this object! + /// + + public enum EventTriggerType + { + PointerEnter = 0, + PointerExit = 1, + PointerDown = 2, + PointerUp = 3, + PointerClick = 4, + Drag = 5, + Drop = 6, + Scroll = 7, + UpdateSelected = 8, + Select = 9, + Deselect = 10, + Move = 11, + InitializePotentialDrag = 12, + BeginDrag = 13, + EndDrag = 14, + Submit = 15, + Cancel = 16 + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventTriggerType.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventTriggerType.cs.meta new file mode 100644 index 0000000..a01a6b5 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventTriggerType.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: fe5c20ffd1028d540b638b6843759dcf +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs new file mode 100644 index 0000000..bf77717 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs @@ -0,0 +1,360 @@ +using System; +using System.Collections.Generic; +using UnityEngine.UI; + +namespace UnityEngine.EventSystems +{ + public static class ExecuteEvents + { + public delegate void EventFunction(T1 handler, BaseEventData eventData); + + public static T ValidateEventData(BaseEventData data) where T : class + { + if ((data as T) == null) + throw new ArgumentException(String.Format("Invalid type: {0} passed to event expecting {1}", data.GetType(), typeof(T))); + return data as T; + } + + private static readonly EventFunction s_PointerEnterHandler = Execute; + + private static void Execute(IPointerEnterHandler handler, BaseEventData eventData) + { + handler.OnPointerEnter(ValidateEventData(eventData)); + } + + private static readonly EventFunction s_PointerExitHandler = Execute; + + private static void Execute(IPointerExitHandler handler, BaseEventData eventData) + { + handler.OnPointerExit(ValidateEventData(eventData)); + } + + private static readonly EventFunction s_PointerDownHandler = Execute; + + private static void Execute(IPointerDownHandler handler, BaseEventData eventData) + { + handler.OnPointerDown(ValidateEventData(eventData)); + } + + private static readonly EventFunction s_PointerUpHandler = Execute; + + private static void Execute(IPointerUpHandler handler, BaseEventData eventData) + { + handler.OnPointerUp(ValidateEventData(eventData)); + } + + private static readonly EventFunction s_PointerClickHandler = Execute; + + private static void Execute(IPointerClickHandler handler, BaseEventData eventData) + { + handler.OnPointerClick(ValidateEventData(eventData)); + } + + private static readonly EventFunction s_InitializePotentialDragHandler = Execute; + + private static void Execute(IInitializePotentialDragHandler handler, BaseEventData eventData) + { + handler.OnInitializePotentialDrag(ValidateEventData(eventData)); + } + + private static readonly EventFunction s_BeginDragHandler = Execute; + + private static void Execute(IBeginDragHandler handler, BaseEventData eventData) + { + handler.OnBeginDrag(ValidateEventData(eventData)); + } + + private static readonly EventFunction s_DragHandler = Execute; + + private static void Execute(IDragHandler handler, BaseEventData eventData) + { + handler.OnDrag(ValidateEventData(eventData)); + } + + private static readonly EventFunction s_EndDragHandler = Execute; + + private static void Execute(IEndDragHandler handler, BaseEventData eventData) + { + handler.OnEndDrag(ValidateEventData(eventData)); + } + + private static readonly EventFunction s_DropHandler = Execute; + + private static void Execute(IDropHandler handler, BaseEventData eventData) + { + handler.OnDrop(ValidateEventData(eventData)); + } + + private static readonly EventFunction s_ScrollHandler = Execute; + + private static void Execute(IScrollHandler handler, BaseEventData eventData) + { + handler.OnScroll(ValidateEventData(eventData)); + } + + private static readonly EventFunction s_UpdateSelectedHandler = Execute; + + private static void Execute(IUpdateSelectedHandler handler, BaseEventData eventData) + { + handler.OnUpdateSelected(eventData); + } + + private static readonly EventFunction s_SelectHandler = Execute; + + private static void Execute(ISelectHandler handler, BaseEventData eventData) + { + handler.OnSelect(eventData); + } + + private static readonly EventFunction s_DeselectHandler = Execute; + + private static void Execute(IDeselectHandler handler, BaseEventData eventData) + { + handler.OnDeselect(eventData); + } + + private static readonly EventFunction s_MoveHandler = Execute; + + private static void Execute(IMoveHandler handler, BaseEventData eventData) + { + handler.OnMove(ValidateEventData(eventData)); + } + + private static readonly EventFunction s_SubmitHandler = Execute; + + private static void Execute(ISubmitHandler handler, BaseEventData eventData) + { + handler.OnSubmit(eventData); + } + + private static readonly EventFunction s_CancelHandler = Execute; + + private static void Execute(ICancelHandler handler, BaseEventData eventData) + { + handler.OnCancel(eventData); + } + + public static EventFunction pointerEnterHandler + { + get { return s_PointerEnterHandler; } + } + + public static EventFunction pointerExitHandler + { + get { return s_PointerExitHandler; } + } + + public static EventFunction pointerDownHandler + { + get { return s_PointerDownHandler; } + } + + public static EventFunction pointerUpHandler + { + get { return s_PointerUpHandler; } + } + + public static EventFunction pointerClickHandler + { + get { return s_PointerClickHandler; } + } + + public static EventFunction initializePotentialDrag + { + get { return s_InitializePotentialDragHandler; } + } + + public static EventFunction beginDragHandler + { + get { return s_BeginDragHandler; } + } + + public static EventFunction dragHandler + { + get { return s_DragHandler; } + } + + public static EventFunction endDragHandler + { + get { return s_EndDragHandler; } + } + + public static EventFunction dropHandler + { + get { return s_DropHandler; } + } + + public static EventFunction scrollHandler + { + get { return s_ScrollHandler; } + } + + public static EventFunction updateSelectedHandler + { + get { return s_UpdateSelectedHandler; } + } + + public static EventFunction selectHandler + { + get { return s_SelectHandler; } + } + + public static EventFunction deselectHandler + { + get { return s_DeselectHandler; } + } + + public static EventFunction moveHandler + { + get { return s_MoveHandler; } + } + + public static EventFunction submitHandler + { + get { return s_SubmitHandler; } + } + + public static EventFunction cancelHandler + { + get { return s_CancelHandler; } + } + + private static void GetEventChain(GameObject root, IList eventChain) + { + eventChain.Clear(); + if (root == null) + return; + + var t = root.transform; + while (t != null) + { + eventChain.Add(t); + t = t.parent; + } + } + + private static readonly ObjectPool> s_HandlerListPool = new ObjectPool>(null, l => l.Clear()); + + public static bool Execute(GameObject target, BaseEventData eventData, EventFunction functor) where T : IEventSystemHandler + { + var internalHandlers = s_HandlerListPool.Get(); + GetEventList(target, internalHandlers); + // if (s_InternalHandlers.Count > 0) + // Debug.Log("Executinng " + typeof (T) + " on " + target); + + for (var i = 0; i < internalHandlers.Count; i++) + { + T arg; + try + { + arg = (T)internalHandlers[i]; + } + catch (Exception e) + { + var temp = internalHandlers[i]; + Debug.LogException(new Exception(string.Format("Type {0} expected {1} received.", typeof(T).Name, temp.GetType().Name), e)); + continue; + } + + try + { + functor(arg, eventData); + } + catch (Exception e) + { + Debug.LogException(e); + } + } + + var handlerCount = internalHandlers.Count; + s_HandlerListPool.Release(internalHandlers); + return handlerCount > 0; + } + + /// + /// Execute the specified event on the first game object underneath the current touch. + /// + private static readonly List s_InternalTransformList = new List(30); + + public static GameObject ExecuteHierarchy(GameObject root, BaseEventData eventData, EventFunction callbackFunction) where T : IEventSystemHandler + { + GetEventChain(root, s_InternalTransformList); + + for (var i = 0; i < s_InternalTransformList.Count; i++) + { + var transform = s_InternalTransformList[i]; + if (Execute(transform.gameObject, eventData, callbackFunction)) + return transform.gameObject; + } + return null; + } + + private static bool ShouldSendToComponent(Component component) where T : IEventSystemHandler + { + var valid = component is T; + if (!valid) + return false; + + var behaviour = component as Behaviour; + if (behaviour != null) + return behaviour.isActiveAndEnabled; + return true; + } + + /// + /// Get the specified object's event event. + /// + private static void GetEventList(GameObject go, IList results) where T : IEventSystemHandler + { + // Debug.LogWarning("GetEventList<" + typeof(T).Name + ">"); + if (results == null) + throw new ArgumentException("Results array is null", "results"); + + if (go == null || !go.activeInHierarchy) + return; + + var components = ListPool.Get(); + go.GetComponents(components); + for (var i = 0; i < components.Count; i++) + { + if (!ShouldSendToComponent(components[i])) + continue; + + // Debug.Log(string.Format("{2} found! On {0}.{1}", go, s_GetComponentsScratch[i].GetType(), typeof(T))); + results.Add(components[i] as IEventSystemHandler); + } + ListPool.Release(components); + // Debug.LogWarning("end GetEventList<" + typeof(T).Name + ">"); + } + + /// + /// Whether the specified game object will be able to handle the specified event. + /// + public static bool CanHandleEvent(GameObject go) where T : IEventSystemHandler + { + var internalHandlers = s_HandlerListPool.Get(); + GetEventList(go, internalHandlers); + var handlerCount = internalHandlers.Count; + s_HandlerListPool.Release(internalHandlers); + return handlerCount != 0; + } + + /// + /// Bubble the specified event on the game object, figuring out which object will actually receive the event. + /// + public static GameObject GetEventHandler(GameObject root) where T : IEventSystemHandler + { + if (root == null) + return null; + + Transform t = root.transform; + while (t != null) + { + if (CanHandleEvent(t.gameObject)) + return t.gameObject; + t = t.parent; + } + return null; + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs.meta new file mode 100644 index 0000000..55a5661 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: f026ab7af2955364588010a84939930e +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules.meta new file mode 100644 index 0000000..377e98b --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 01c44af785d19084ba79209e04e7e3b3 +folderAsset: yes +timeCreated: 1602119280 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInput.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInput.cs new file mode 100644 index 0000000..a761057 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInput.cs @@ -0,0 +1,77 @@ +namespace UnityEngine.EventSystems +{ + public class BaseInput : UIBehaviour + { + public virtual string compositionString + { + get { return Input.compositionString; } + } + + public virtual IMECompositionMode imeCompositionMode + { + get { return Input.imeCompositionMode; } + set { Input.imeCompositionMode = value; } + } + + public virtual Vector2 compositionCursorPos + { + get { return Input.compositionCursorPos; } + set { Input.compositionCursorPos = value; } + } + + public virtual bool mousePresent + { + get { return Input.mousePresent; } + } + + public virtual bool GetMouseButtonDown(int button) + { + return Input.GetMouseButtonDown(button); + } + + public virtual bool GetMouseButtonUp(int button) + { + return Input.GetMouseButtonUp(button); + } + + public virtual bool GetMouseButton(int button) + { + return Input.GetMouseButton(button); + } + + public virtual Vector2 mousePosition + { + get { return Input.mousePosition; } + } + + public virtual Vector2 mouseScrollDelta + { + get { return Input.mouseScrollDelta; } + } + + public virtual bool touchSupported + { + get { return Input.touchSupported; } + } + + public virtual int touchCount + { + get { return Input.touchCount; } + } + + public virtual Touch GetTouch(int index) + { + return Input.GetTouch(index); + } + + public virtual float GetAxisRaw(string axisName) + { + return Input.GetAxisRaw(axisName); + } + + public virtual bool GetButtonDown(string buttonName) + { + return Input.GetButtonDown(buttonName); + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInput.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInput.cs.meta new file mode 100644 index 0000000..57a6da5 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInput.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 6b9bc579ce1ae3148add9cf327b4ff2e +timeCreated: 1602119378 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInputModule.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInputModule.cs new file mode 100644 index 0000000..7125a4d --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInputModule.cs @@ -0,0 +1,231 @@ +using System; +using System.Collections.Generic; + +namespace UnityEngine.EventSystems +{ + [RequireComponent(typeof(EventSystem))] + public abstract class BaseInputModule : UIBehaviour + { + [NonSerialized] + protected List m_RaycastResultCache = new List(); + + private AxisEventData m_AxisEventData; + + private EventSystem m_EventSystem; + private BaseEventData m_BaseEventData; + + protected BaseInput m_InputOverride; + private BaseInput m_DefaultInput; + + public BaseInput input + { + get + { + if (m_InputOverride != null) + return m_InputOverride; + + if (m_DefaultInput == null) + { + var inputs = GetComponents(); + foreach (var baseInput in inputs) + { + // We dont want to use any classes that derrive from BaseInput for default. + if (baseInput != null && baseInput.GetType() == typeof(BaseInput)) + { + m_DefaultInput = baseInput; + break; + } + } + + if (m_DefaultInput == null) + m_DefaultInput = gameObject.AddComponent(); + } + + return m_DefaultInput; + } + } + + protected EventSystem eventSystem + { + get { return m_EventSystem; } + } + + protected override void OnEnable() + { + base.OnEnable(); + m_EventSystem = GetComponent(); + m_EventSystem.UpdateModules(); + } + + protected override void OnDisable() + { + m_EventSystem.UpdateModules(); + base.OnDisable(); + } + + public abstract void Process(); + + protected static RaycastResult FindFirstRaycast(List candidates) + { + for (var i = 0; i < candidates.Count; ++i) + { + if (candidates[i].gameObject == null) + continue; + + return candidates[i]; + } + return new RaycastResult(); + } + + protected static MoveDirection DetermineMoveDirection(float x, float y) + { + return DetermineMoveDirection(x, y, 0.6f); + } + + protected static MoveDirection DetermineMoveDirection(float x, float y, float deadZone) + { + // if vector is too small... just return + if (new Vector2(x, y).sqrMagnitude < deadZone * deadZone) + return MoveDirection.None; + + if (Mathf.Abs(x) > Mathf.Abs(y)) + { + if (x > 0) + return MoveDirection.Right; + return MoveDirection.Left; + } + else + { + if (y > 0) + return MoveDirection.Up; + return MoveDirection.Down; + } + } + + protected static GameObject FindCommonRoot(GameObject g1, GameObject g2) + { + if (g1 == null || g2 == null) + return null; + + var t1 = g1.transform; + while (t1 != null) + { + var t2 = g2.transform; + while (t2 != null) + { + if (t1 == t2) + return t1.gameObject; + t2 = t2.parent; + } + t1 = t1.parent; + } + return null; + } + + // walk up the tree till a common root between the last entered and the current entered is foung + // send exit events up to (but not inluding) the common root. Then send enter events up to + // (but not including the common root). + protected void HandlePointerExitAndEnter(PointerEventData currentPointerData, GameObject newEnterTarget) + { + // if we have no target / pointerEnter has been deleted + // just send exit events to anything we are tracking + // then exit + if (newEnterTarget == null || currentPointerData.pointerEnter == null) + { + for (var i = 0; i < currentPointerData.hovered.Count; ++i) + ExecuteEvents.Execute(currentPointerData.hovered[i], currentPointerData, ExecuteEvents.pointerExitHandler); + + currentPointerData.hovered.Clear(); + + if (newEnterTarget == null) + { + currentPointerData.pointerEnter = newEnterTarget; + return; + } + } + + // if we have not changed hover target + if (currentPointerData.pointerEnter == newEnterTarget && newEnterTarget) + return; + + GameObject commonRoot = FindCommonRoot(currentPointerData.pointerEnter, newEnterTarget); + + // and we already an entered object from last time + if (currentPointerData.pointerEnter != null) + { + // send exit handler call to all elements in the chain + // until we reach the new target, or null! + Transform t = currentPointerData.pointerEnter.transform; + + while (t != null) + { + // if we reach the common root break out! + if (commonRoot != null && commonRoot.transform == t) + break; + + ExecuteEvents.Execute(t.gameObject, currentPointerData, ExecuteEvents.pointerExitHandler); + currentPointerData.hovered.Remove(t.gameObject); + t = t.parent; + } + } + + // now issue the enter call up to but not including the common root + currentPointerData.pointerEnter = newEnterTarget; + if (newEnterTarget != null) + { + Transform t = newEnterTarget.transform; + + while (t != null && t.gameObject != commonRoot) + { + ExecuteEvents.Execute(t.gameObject, currentPointerData, ExecuteEvents.pointerEnterHandler); + currentPointerData.hovered.Add(t.gameObject); + t = t.parent; + } + } + } + + protected virtual AxisEventData GetAxisEventData(float x, float y, float moveDeadZone) + { + if (m_AxisEventData == null) + m_AxisEventData = new AxisEventData(eventSystem); + + m_AxisEventData.Reset(); + m_AxisEventData.moveVector = new Vector2(x, y); + m_AxisEventData.moveDir = DetermineMoveDirection(x, y, moveDeadZone); + return m_AxisEventData; + } + + protected virtual BaseEventData GetBaseEventData() + { + if (m_BaseEventData == null) + m_BaseEventData = new BaseEventData(eventSystem); + + m_BaseEventData.Reset(); + return m_BaseEventData; + } + + public virtual bool IsPointerOverGameObject(int pointerId) + { + return false; + } + + public virtual bool ShouldActivateModule() + { + return enabled && gameObject.activeInHierarchy; + } + + public virtual void DeactivateModule() + {} + + public virtual void ActivateModule() + {} + + public virtual void UpdateModule() + {} + + public virtual bool IsModuleSupported() + { + return true; + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInputModule.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInputModule.cs.meta new file mode 100644 index 0000000..5108b8b --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInputModule.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 87c800b13211f034e90e29ad88dd2d60 +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/PointerInputModule.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/PointerInputModule.cs new file mode 100644 index 0000000..d31f433 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/PointerInputModule.cs @@ -0,0 +1,328 @@ +using System.Collections.Generic; +using System.Text; +using UnityEngine.UI; + +namespace UnityEngine.EventSystems +{ + public abstract class PointerInputModule : BaseInputModule + { + public const int kMouseLeftId = -1; + public const int kMouseRightId = -2; + public const int kMouseMiddleId = -3; + + public const int kFakeTouchesId = -4; + + protected Dictionary m_PointerData = new Dictionary(); + + protected bool GetPointerData(int id, out PointerEventData data, bool create) + { + if (!m_PointerData.TryGetValue(id, out data) && create) + { + data = new PointerEventData(eventSystem) + { + pointerId = id, + }; + m_PointerData.Add(id, data); + return true; + } + return false; + } + + protected void RemovePointerData(PointerEventData data) + { + m_PointerData.Remove(data.pointerId); + } + + protected PointerEventData GetTouchPointerEventData(Touch input, out bool pressed, out bool released) + { + PointerEventData pointerData; + var created = GetPointerData(input.fingerId, out pointerData, true); + + pointerData.Reset(); + + pressed = created || (input.phase == TouchPhase.Began); + released = (input.phase == TouchPhase.Canceled) || (input.phase == TouchPhase.Ended); + + if (created) + pointerData.position = input.position; + + if (pressed) + pointerData.delta = Vector2.zero; + else + pointerData.delta = input.position - pointerData.position; + + pointerData.position = input.position; + + pointerData.button = PointerEventData.InputButton.Left; + + eventSystem.RaycastAll(pointerData, m_RaycastResultCache); + + var raycast = FindFirstRaycast(m_RaycastResultCache); + pointerData.pointerCurrentRaycast = raycast; + m_RaycastResultCache.Clear(); + return pointerData; + } + + protected void CopyFromTo(PointerEventData @from, PointerEventData @to) + { + @to.position = @from.position; + @to.delta = @from.delta; + @to.scrollDelta = @from.scrollDelta; + @to.pointerCurrentRaycast = @from.pointerCurrentRaycast; + @to.pointerEnter = @from.pointerEnter; + } + + protected PointerEventData.FramePressState StateForMouseButton(int buttonId) + { + var pressed = input.GetMouseButtonDown(buttonId); + var released = input.GetMouseButtonUp(buttonId); + if (pressed && released) + return PointerEventData.FramePressState.PressedAndReleased; + if (pressed) + return PointerEventData.FramePressState.Pressed; + if (released) + return PointerEventData.FramePressState.Released; + return PointerEventData.FramePressState.NotChanged; + } + + protected class ButtonState + { + private PointerEventData.InputButton m_Button = PointerEventData.InputButton.Left; + + public MouseButtonEventData eventData + { + get { return m_EventData; } + set { m_EventData = value; } + } + + public PointerEventData.InputButton button + { + get { return m_Button; } + set { m_Button = value; } + } + + private MouseButtonEventData m_EventData; + } + + protected class MouseState + { + private List m_TrackedButtons = new List(); + + public bool AnyPressesThisFrame() + { + for (int i = 0; i < m_TrackedButtons.Count; i++) + { + if (m_TrackedButtons[i].eventData.PressedThisFrame()) + return true; + } + return false; + } + + public bool AnyReleasesThisFrame() + { + for (int i = 0; i < m_TrackedButtons.Count; i++) + { + if (m_TrackedButtons[i].eventData.ReleasedThisFrame()) + return true; + } + return false; + } + + public ButtonState GetButtonState(PointerEventData.InputButton button) + { + ButtonState tracked = null; + for (int i = 0; i < m_TrackedButtons.Count; i++) + { + if (m_TrackedButtons[i].button == button) + { + tracked = m_TrackedButtons[i]; + break; + } + } + + if (tracked == null) + { + tracked = new ButtonState { button = button, eventData = new MouseButtonEventData() }; + m_TrackedButtons.Add(tracked); + } + return tracked; + } + + public void SetButtonState(PointerEventData.InputButton button, PointerEventData.FramePressState stateForMouseButton, PointerEventData data) + { + var toModify = GetButtonState(button); + toModify.eventData.buttonState = stateForMouseButton; + toModify.eventData.buttonData = data; + } + } + + public class MouseButtonEventData + { + public PointerEventData.FramePressState buttonState; + public PointerEventData buttonData; + + public bool PressedThisFrame() + { + return buttonState == PointerEventData.FramePressState.Pressed || buttonState == PointerEventData.FramePressState.PressedAndReleased; + } + + public bool ReleasedThisFrame() + { + return buttonState == PointerEventData.FramePressState.Released || buttonState == PointerEventData.FramePressState.PressedAndReleased; + } + } + + private readonly MouseState m_MouseState = new MouseState(); + + protected virtual MouseState GetMousePointerEventData() + { + return GetMousePointerEventData(0); + } + + protected virtual MouseState GetMousePointerEventData(int id) + { + // Populate the left button... + PointerEventData leftData; + var created = GetPointerData(kMouseLeftId, out leftData, true); + + leftData.Reset(); + + if (created) + leftData.position = input.mousePosition; + + Vector2 pos = input.mousePosition; + if (Cursor.lockState == CursorLockMode.Locked) + { + // We don't want to do ANY cursor-based interaction when the mouse is locked + leftData.position = new Vector2(-1.0f, -1.0f); + leftData.delta = Vector2.zero; + } + else + { + leftData.delta = pos - leftData.position; + leftData.position = pos; + } + leftData.scrollDelta = input.mouseScrollDelta; + leftData.button = PointerEventData.InputButton.Left; + eventSystem.RaycastAll(leftData, m_RaycastResultCache); + var raycast = FindFirstRaycast(m_RaycastResultCache); + leftData.pointerCurrentRaycast = raycast; + m_RaycastResultCache.Clear(); + + // copy the apropriate data into right and middle slots + PointerEventData rightData; + GetPointerData(kMouseRightId, out rightData, true); + CopyFromTo(leftData, rightData); + rightData.button = PointerEventData.InputButton.Right; + + PointerEventData middleData; + GetPointerData(kMouseMiddleId, out middleData, true); + CopyFromTo(leftData, middleData); + middleData.button = PointerEventData.InputButton.Middle; + + m_MouseState.SetButtonState(PointerEventData.InputButton.Left, StateForMouseButton(0), leftData); + m_MouseState.SetButtonState(PointerEventData.InputButton.Right, StateForMouseButton(1), rightData); + m_MouseState.SetButtonState(PointerEventData.InputButton.Middle, StateForMouseButton(2), middleData); + + return m_MouseState; + } + + protected PointerEventData GetLastPointerEventData(int id) + { + PointerEventData data; + GetPointerData(id, out data, false); + return data; + } + + private static bool ShouldStartDrag(Vector2 pressPos, Vector2 currentPos, float threshold, bool useDragThreshold) + { + if (!useDragThreshold) + return true; + + return (pressPos - currentPos).sqrMagnitude >= threshold * threshold; + } + + protected virtual void ProcessMove(PointerEventData pointerEvent) + { + var targetGO = (Cursor.lockState == CursorLockMode.Locked ? null : pointerEvent.pointerCurrentRaycast.gameObject); + HandlePointerExitAndEnter(pointerEvent, targetGO); + } + + protected virtual void ProcessDrag(PointerEventData pointerEvent) + { + if (!pointerEvent.IsPointerMoving() || + Cursor.lockState == CursorLockMode.Locked || + pointerEvent.pointerDrag == null) + return; + + if (!pointerEvent.dragging + && ShouldStartDrag(pointerEvent.pressPosition, pointerEvent.position, eventSystem.pixelDragThreshold, pointerEvent.useDragThreshold)) + { + ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.beginDragHandler); + pointerEvent.dragging = true; + } + + // Drag notification + if (pointerEvent.dragging) + { + // Before doing drag we should cancel any pointer down state + // And clear selection! + if (pointerEvent.pointerPress != pointerEvent.pointerDrag) + { + ExecuteEvents.Execute(pointerEvent.pointerPress, pointerEvent, ExecuteEvents.pointerUpHandler); + + pointerEvent.eligibleForClick = false; + pointerEvent.pointerPress = null; + pointerEvent.rawPointerPress = null; + } + ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.dragHandler); + } + } + + public override bool IsPointerOverGameObject(int pointerId) + { + var lastPointer = GetLastPointerEventData(pointerId); + if (lastPointer != null) + return lastPointer.pointerEnter != null; + return false; + } + + protected void ClearSelection() + { + var baseEventData = GetBaseEventData(); + + foreach (var pointer in m_PointerData.Values) + { + // clear all selection + HandlePointerExitAndEnter(pointer, null); + } + + m_PointerData.Clear(); + eventSystem.SetSelectedGameObject(null, baseEventData); + } + + public override string ToString() + { + var sb = new StringBuilder("Pointer Input Module of type: " + GetType()); + sb.AppendLine(); + foreach (var pointer in m_PointerData) + { + if (pointer.Value == null) + continue; + sb.AppendLine("Pointer: " + pointer.Key); + sb.AppendLine(pointer.Value.ToString()); + } + return sb.ToString(); + } + + protected void DeselectIfSelectionChanged(GameObject currentOverGo, BaseEventData pointerEvent) + { + // Selection tracking + var selectHandlerGO = ExecuteEvents.GetEventHandler(currentOverGo); + // if we have clicked something new, deselect the old thing + // leave 'selection handling' up to the press event though. + if (selectHandlerGO != eventSystem.currentSelectedGameObject) + eventSystem.SetSelectedGameObject(null, pointerEvent); + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/PointerInputModule.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/PointerInputModule.cs.meta new file mode 100644 index 0000000..e4f85e9 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/PointerInputModule.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ca2a80b2630ad814e85c9b5d17e69cbf +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/StandaloneInputModule.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/StandaloneInputModule.cs new file mode 100644 index 0000000..ee6f216 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/StandaloneInputModule.cs @@ -0,0 +1,588 @@ +using System; +using UnityEngine; +using UnityEngine.Serialization; + +namespace UnityEngine.EventSystems +{ + [AddComponentMenu("Event/Standalone Input Module")] + public class StandaloneInputModule : PointerInputModule + { + private float m_PrevActionTime; + private Vector2 m_LastMoveVector; + private int m_ConsecutiveMoveCount = 0; + + private Vector2 m_LastMousePosition; + private Vector2 m_MousePosition; + + private GameObject m_CurrentFocusedGameObject; + + protected StandaloneInputModule() + { + } + + [Obsolete("Mode is no longer needed on input module as it handles both mouse and keyboard simultaneously.", false)] + public enum InputMode + { + Mouse, + Buttons + } + + [Obsolete("Mode is no longer needed on input module as it handles both mouse and keyboard simultaneously.", false)] + public InputMode inputMode + { + get { return InputMode.Mouse; } + } + + [SerializeField] + private string m_HorizontalAxis = "Horizontal"; + + /// + /// Name of the vertical axis for movement (if axis events are used). + /// + [SerializeField] + private string m_VerticalAxis = "Vertical"; + + /// + /// Name of the submit button. + /// + [SerializeField] + private string m_SubmitButton = "Submit"; + + /// + /// Name of the submit button. + /// + [SerializeField] + private string m_CancelButton = "Cancel"; + + [SerializeField] + private float m_InputActionsPerSecond = 10; + + [SerializeField] + private float m_RepeatDelay = 0.5f; + + [SerializeField] + [FormerlySerializedAs("m_AllowActivationOnMobileDevice")] + private bool m_ForceModuleActive; + + [Obsolete("allowActivationOnMobileDevice has been deprecated. Use forceModuleActive instead (UnityUpgradable) -> forceModuleActive")] + public bool allowActivationOnMobileDevice + { + get { return m_ForceModuleActive; } + set { m_ForceModuleActive = value; } + } + + public bool forceModuleActive + { + get { return m_ForceModuleActive; } + set { m_ForceModuleActive = value; } + } + + public float inputActionsPerSecond + { + get { return m_InputActionsPerSecond; } + set { m_InputActionsPerSecond = value; } + } + + public float repeatDelay + { + get { return m_RepeatDelay; } + set { m_RepeatDelay = value; } + } + + /// + /// Name of the horizontal axis for movement (if axis events are used). + /// + public string horizontalAxis + { + get { return m_HorizontalAxis; } + set { m_HorizontalAxis = value; } + } + + /// + /// Name of the vertical axis for movement (if axis events are used). + /// + public string verticalAxis + { + get { return m_VerticalAxis; } + set { m_VerticalAxis = value; } + } + + public string submitButton + { + get { return m_SubmitButton; } + set { m_SubmitButton = value; } + } + + public string cancelButton + { + get { return m_CancelButton; } + set { m_CancelButton = value; } + } + + private bool ShouldIgnoreEventsOnNoFocus() + { + switch (SystemInfo.operatingSystemFamily) + { + case OperatingSystemFamily.Windows: + case OperatingSystemFamily.Linux: + case OperatingSystemFamily.MacOSX: +#if UNITY_EDITOR + if (UnityEditor.EditorApplication.isRemoteConnected) + return false; +#endif + return true; + default: + return false; + } + } + + public override void UpdateModule() + { + if (!eventSystem.isFocused && ShouldIgnoreEventsOnNoFocus()) + return; + + m_LastMousePosition = m_MousePosition; + m_MousePosition = input.mousePosition; + } + + public override bool IsModuleSupported() + { + return m_ForceModuleActive || input.mousePresent || input.touchSupported; + } + + public override bool ShouldActivateModule() + { + if (!base.ShouldActivateModule()) + return false; + + var shouldActivate = m_ForceModuleActive; + shouldActivate |= input.GetButtonDown(m_SubmitButton); + shouldActivate |= input.GetButtonDown(m_CancelButton); + shouldActivate |= !Mathf.Approximately(input.GetAxisRaw(m_HorizontalAxis), 0.0f); + shouldActivate |= !Mathf.Approximately(input.GetAxisRaw(m_VerticalAxis), 0.0f); + shouldActivate |= (m_MousePosition - m_LastMousePosition).sqrMagnitude > 0.0f; + shouldActivate |= input.GetMouseButtonDown(0); + + if (input.touchCount > 0) + shouldActivate = true; + + return shouldActivate; + } + + public override void ActivateModule() + { + if (!eventSystem.isFocused && ShouldIgnoreEventsOnNoFocus()) + return; + + base.ActivateModule(); + m_MousePosition = input.mousePosition; + m_LastMousePosition = input.mousePosition; + + var toSelect = eventSystem.currentSelectedGameObject; + if (toSelect == null) + toSelect = eventSystem.firstSelectedGameObject; + + eventSystem.SetSelectedGameObject(toSelect, GetBaseEventData()); + } + + public override void DeactivateModule() + { + base.DeactivateModule(); + ClearSelection(); + } + + public override void Process() + { + if (!eventSystem.isFocused && ShouldIgnoreEventsOnNoFocus()) + return; + + bool usedEvent = SendUpdateEventToSelectedObject(); + + if (eventSystem.sendNavigationEvents) + { + if (!usedEvent) + usedEvent |= SendMoveEventToSelectedObject(); + + if (!usedEvent) + SendSubmitEventToSelectedObject(); + } + + // touch needs to take precedence because of the mouse emulation layer + if (!ProcessTouchEvents() && input.mousePresent) + ProcessMouseEvent(); + } + + private bool ProcessTouchEvents() + { + for (int i = 0; i < input.touchCount; ++i) + { + Touch touch = input.GetTouch(i); + + if (touch.type == TouchType.Indirect) + continue; + + bool released; + bool pressed; + var pointer = GetTouchPointerEventData(touch, out pressed, out released); + + ProcessTouchPress(pointer, pressed, released); + + if (!released) + { + ProcessMove(pointer); + ProcessDrag(pointer); + } + else + RemovePointerData(pointer); + } + return input.touchCount > 0; + } + + protected void ProcessTouchPress(PointerEventData pointerEvent, bool pressed, bool released) + { + var currentOverGo = pointerEvent.pointerCurrentRaycast.gameObject; + + // PointerDown notification + if (pressed) + { + pointerEvent.eligibleForClick = true; + pointerEvent.delta = Vector2.zero; + pointerEvent.dragging = false; + pointerEvent.useDragThreshold = true; + pointerEvent.pressPosition = pointerEvent.position; + pointerEvent.pointerPressRaycast = pointerEvent.pointerCurrentRaycast; + + DeselectIfSelectionChanged(currentOverGo, pointerEvent); + + if (pointerEvent.pointerEnter != currentOverGo) + { + // send a pointer enter to the touched element if it isn't the one to select... + HandlePointerExitAndEnter(pointerEvent, currentOverGo); + pointerEvent.pointerEnter = currentOverGo; + } + + // search for the control that will receive the press + // if we can't find a press handler set the press + // handler to be what would receive a click. + var newPressed = ExecuteEvents.ExecuteHierarchy(currentOverGo, pointerEvent, ExecuteEvents.pointerDownHandler); + + // didnt find a press handler... search for a click handler + if (newPressed == null) + newPressed = ExecuteEvents.GetEventHandler(currentOverGo); + + // Debug.Log("Pressed: " + newPressed); + + float time = Time.unscaledTime; + + if (newPressed == pointerEvent.lastPress) + { + var diffTime = time - pointerEvent.clickTime; + if (diffTime < 0.3f) + ++pointerEvent.clickCount; + else + pointerEvent.clickCount = 1; + + pointerEvent.clickTime = time; + } + else + { + pointerEvent.clickCount = 1; + } + + pointerEvent.pointerPress = newPressed; + pointerEvent.rawPointerPress = currentOverGo; + + pointerEvent.clickTime = time; + + // Save the drag handler as well + pointerEvent.pointerDrag = ExecuteEvents.GetEventHandler(currentOverGo); + + if (pointerEvent.pointerDrag != null) + ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.initializePotentialDrag); + } + + // PointerUp notification + if (released) + { + // Debug.Log("Executing pressup on: " + pointer.pointerPress); + ExecuteEvents.Execute(pointerEvent.pointerPress, pointerEvent, ExecuteEvents.pointerUpHandler); + + // Debug.Log("KeyCode: " + pointer.eventData.keyCode); + + // see if we mouse up on the same element that we clicked on... + var pointerUpHandler = ExecuteEvents.GetEventHandler(currentOverGo); + + // PointerClick and Drop events + if (pointerEvent.pointerPress == pointerUpHandler && pointerEvent.eligibleForClick) + { + ExecuteEvents.Execute(pointerEvent.pointerPress, pointerEvent, ExecuteEvents.pointerClickHandler); + } + else if (pointerEvent.pointerDrag != null && pointerEvent.dragging) + { + ExecuteEvents.ExecuteHierarchy(currentOverGo, pointerEvent, ExecuteEvents.dropHandler); + } + + pointerEvent.eligibleForClick = false; + pointerEvent.pointerPress = null; + pointerEvent.rawPointerPress = null; + + if (pointerEvent.pointerDrag != null && pointerEvent.dragging) + ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.endDragHandler); + + pointerEvent.dragging = false; + pointerEvent.pointerDrag = null; + + // send exit events as we need to simulate this on touch up on touch device + ExecuteEvents.ExecuteHierarchy(pointerEvent.pointerEnter, pointerEvent, ExecuteEvents.pointerExitHandler); + pointerEvent.pointerEnter = null; + } + } + + /// + /// Process submit keys. + /// + protected bool SendSubmitEventToSelectedObject() + { + if (eventSystem.currentSelectedGameObject == null) + return false; + + var data = GetBaseEventData(); + if (input.GetButtonDown(m_SubmitButton)) + ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.submitHandler); + + if (input.GetButtonDown(m_CancelButton)) + ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.cancelHandler); + return data.used; + } + + private Vector2 GetRawMoveVector() + { + Vector2 move = Vector2.zero; + move.x = input.GetAxisRaw(m_HorizontalAxis); + move.y = input.GetAxisRaw(m_VerticalAxis); + + if (input.GetButtonDown(m_HorizontalAxis)) + { + if (move.x < 0) + move.x = -1f; + if (move.x > 0) + move.x = 1f; + } + if (input.GetButtonDown(m_VerticalAxis)) + { + if (move.y < 0) + move.y = -1f; + if (move.y > 0) + move.y = 1f; + } + return move; + } + + /// + /// Process keyboard events. + /// + protected bool SendMoveEventToSelectedObject() + { + float time = Time.unscaledTime; + + Vector2 movement = GetRawMoveVector(); + if (Mathf.Approximately(movement.x, 0f) && Mathf.Approximately(movement.y, 0f)) + { + m_ConsecutiveMoveCount = 0; + return false; + } + + // If user pressed key again, always allow event + bool allow = input.GetButtonDown(m_HorizontalAxis) || input.GetButtonDown(m_VerticalAxis); + bool similarDir = (Vector2.Dot(movement, m_LastMoveVector) > 0); + if (!allow) + { + // Otherwise, user held down key or axis. + // If direction didn't change at least 90 degrees, wait for delay before allowing consequtive event. + if (similarDir && m_ConsecutiveMoveCount == 1) + allow = (time > m_PrevActionTime + m_RepeatDelay); + // If direction changed at least 90 degree, or we already had the delay, repeat at repeat rate. + else + allow = (time > m_PrevActionTime + 1f / m_InputActionsPerSecond); + } + if (!allow) + return false; + + // Debug.Log(m_ProcessingEvent.rawType + " axis:" + m_AllowAxisEvents + " value:" + "(" + x + "," + y + ")"); + var axisEventData = GetAxisEventData(movement.x, movement.y, 0.6f); + + if (axisEventData.moveDir != MoveDirection.None) + { + ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, axisEventData, ExecuteEvents.moveHandler); + if (!similarDir) + m_ConsecutiveMoveCount = 0; + m_ConsecutiveMoveCount++; + m_PrevActionTime = time; + m_LastMoveVector = movement; + } + else + { + m_ConsecutiveMoveCount = 0; + } + + return axisEventData.used; + } + + protected void ProcessMouseEvent() + { + ProcessMouseEvent(0); + } + + [Obsolete("This method is no longer checked, overriding it with return true does nothing!")] + protected virtual bool ForceAutoSelect() + { + return false; + } + + /// + /// Process all mouse events. + /// + protected void ProcessMouseEvent(int id) + { + var mouseData = GetMousePointerEventData(id); + var leftButtonData = mouseData.GetButtonState(PointerEventData.InputButton.Left).eventData; + + m_CurrentFocusedGameObject = leftButtonData.buttonData.pointerCurrentRaycast.gameObject; + + // Process the first mouse button fully + ProcessMousePress(leftButtonData); + ProcessMove(leftButtonData.buttonData); + ProcessDrag(leftButtonData.buttonData); + + // Now process right / middle clicks + ProcessMousePress(mouseData.GetButtonState(PointerEventData.InputButton.Right).eventData); + ProcessDrag(mouseData.GetButtonState(PointerEventData.InputButton.Right).eventData.buttonData); + ProcessMousePress(mouseData.GetButtonState(PointerEventData.InputButton.Middle).eventData); + ProcessDrag(mouseData.GetButtonState(PointerEventData.InputButton.Middle).eventData.buttonData); + + if (!Mathf.Approximately(leftButtonData.buttonData.scrollDelta.sqrMagnitude, 0.0f)) + { + var scrollHandler = ExecuteEvents.GetEventHandler(leftButtonData.buttonData.pointerCurrentRaycast.gameObject); + ExecuteEvents.ExecuteHierarchy(scrollHandler, leftButtonData.buttonData, ExecuteEvents.scrollHandler); + } + } + + protected bool SendUpdateEventToSelectedObject() + { + if (eventSystem.currentSelectedGameObject == null) + return false; + + var data = GetBaseEventData(); + ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.updateSelectedHandler); + return data.used; + } + + /// + /// Process the current mouse press. + /// + protected void ProcessMousePress(MouseButtonEventData data) + { + var pointerEvent = data.buttonData; + var currentOverGo = pointerEvent.pointerCurrentRaycast.gameObject; + + // PointerDown notification + if (data.PressedThisFrame()) + { + pointerEvent.eligibleForClick = true; + pointerEvent.delta = Vector2.zero; + pointerEvent.dragging = false; + pointerEvent.useDragThreshold = true; + pointerEvent.pressPosition = pointerEvent.position; + pointerEvent.pointerPressRaycast = pointerEvent.pointerCurrentRaycast; + + DeselectIfSelectionChanged(currentOverGo, pointerEvent); + + // search for the control that will receive the press + // if we can't find a press handler set the press + // handler to be what would receive a click. + var newPressed = ExecuteEvents.ExecuteHierarchy(currentOverGo, pointerEvent, ExecuteEvents.pointerDownHandler); + + // didnt find a press handler... search for a click handler + if (newPressed == null) + newPressed = ExecuteEvents.GetEventHandler(currentOverGo); + + // Debug.Log("Pressed: " + newPressed); + + float time = Time.unscaledTime; + + if (newPressed == pointerEvent.lastPress) + { + var diffTime = time - pointerEvent.clickTime; + if (diffTime < 0.3f) + ++pointerEvent.clickCount; + else + pointerEvent.clickCount = 1; + + pointerEvent.clickTime = time; + } + else + { + pointerEvent.clickCount = 1; + } + + pointerEvent.pointerPress = newPressed; + pointerEvent.rawPointerPress = currentOverGo; + + pointerEvent.clickTime = time; + + // Save the drag handler as well + pointerEvent.pointerDrag = ExecuteEvents.GetEventHandler(currentOverGo); + + if (pointerEvent.pointerDrag != null) + ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.initializePotentialDrag); + } + + // PointerUp notification + if (data.ReleasedThisFrame()) + { + // Debug.Log("Executing pressup on: " + pointer.pointerPress); + ExecuteEvents.Execute(pointerEvent.pointerPress, pointerEvent, ExecuteEvents.pointerUpHandler); + + // Debug.Log("KeyCode: " + pointer.eventData.keyCode); + + // see if we mouse up on the same element that we clicked on... + var pointerUpHandler = ExecuteEvents.GetEventHandler(currentOverGo); + + // PointerClick and Drop events + if (pointerEvent.pointerPress == pointerUpHandler && pointerEvent.eligibleForClick) + { + ExecuteEvents.Execute(pointerEvent.pointerPress, pointerEvent, ExecuteEvents.pointerClickHandler); + } + else if (pointerEvent.pointerDrag != null && pointerEvent.dragging) + { + ExecuteEvents.ExecuteHierarchy(currentOverGo, pointerEvent, ExecuteEvents.dropHandler); + } + + pointerEvent.eligibleForClick = false; + pointerEvent.pointerPress = null; + pointerEvent.rawPointerPress = null; + + if (pointerEvent.pointerDrag != null && pointerEvent.dragging) + ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.endDragHandler); + + pointerEvent.dragging = false; + pointerEvent.pointerDrag = null; + + // redo pointer enter / exit to refresh state + // so that if we moused over somethign that ignored it before + // due to having pressed on something else + // it now gets it. + if (currentOverGo != pointerEvent.pointerEnter) + { + HandlePointerExitAndEnter(pointerEvent, null); + HandlePointerExitAndEnter(pointerEvent, currentOverGo); + } + } + } + + protected GameObject GetCurrentFocusedGameObject() + { + return m_CurrentFocusedGameObject; + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/StandaloneInputModule.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/StandaloneInputModule.cs.meta new file mode 100644 index 0000000..dde31b7 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/StandaloneInputModule.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: e2665fa6a1fb2474d8a5c19f72f8d0c6 +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/TouchInputModule.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/TouchInputModule.cs new file mode 100644 index 0000000..4f04f42 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/TouchInputModule.cs @@ -0,0 +1,260 @@ +using System; +using System.Text; +using UnityEngine.Serialization; + +namespace UnityEngine.EventSystems +{ + [Obsolete("TouchInputModule is no longer required as Touch input is now handled in StandaloneInputModule.")] + [AddComponentMenu("Event/Touch Input Module")] + public class TouchInputModule : PointerInputModule + { + protected TouchInputModule() + {} + + private Vector2 m_LastMousePosition; + private Vector2 m_MousePosition; + + [SerializeField] + [FormerlySerializedAs("m_AllowActivationOnStandalone")] + private bool m_ForceModuleActive; + + [Obsolete("allowActivationOnStandalone has been deprecated. Use forceModuleActive instead (UnityUpgradable) -> forceModuleActive")] + public bool allowActivationOnStandalone + { + get { return m_ForceModuleActive; } + set { m_ForceModuleActive = value; } + } + + public bool forceModuleActive + { + get { return m_ForceModuleActive; } + set { m_ForceModuleActive = value; } + } + + public override void UpdateModule() + { + m_LastMousePosition = m_MousePosition; + m_MousePosition = input.mousePosition; + } + + public override bool IsModuleSupported() + { + return forceModuleActive || input.touchSupported; + } + + public override bool ShouldActivateModule() + { + if (!base.ShouldActivateModule()) + return false; + + if (m_ForceModuleActive) + return true; + + if (UseFakeInput()) + { + bool wantsEnable = input.GetMouseButtonDown(0); + + wantsEnable |= (m_MousePosition - m_LastMousePosition).sqrMagnitude > 0.0f; + return wantsEnable; + } + + if (input.touchCount > 0) + return true; + + return false; + } + + private bool UseFakeInput() + { + return !input.touchSupported; + } + + public override void Process() + { + if (UseFakeInput()) + FakeTouches(); + else + ProcessTouchEvents(); + } + + /// + /// For debugging touch-based devices using the mouse. + /// + private void FakeTouches() + { + var pointerData = GetMousePointerEventData(0); + + var leftPressData = pointerData.GetButtonState(PointerEventData.InputButton.Left).eventData; + + // fake touches... on press clear delta + if (leftPressData.PressedThisFrame()) + leftPressData.buttonData.delta = Vector2.zero; + + ProcessTouchPress(leftPressData.buttonData, leftPressData.PressedThisFrame(), leftPressData.ReleasedThisFrame()); + + // only process move if we are pressed... + if (input.GetMouseButton(0)) + { + ProcessMove(leftPressData.buttonData); + ProcessDrag(leftPressData.buttonData); + } + } + + /// + /// Process all touch events. + /// + private void ProcessTouchEvents() + { + for (int i = 0; i < input.touchCount; ++i) + { + Touch touch = input.GetTouch(i); + + if (touch.type == TouchType.Indirect) + continue; + + bool released; + bool pressed; + var pointer = GetTouchPointerEventData(touch, out pressed, out released); + + ProcessTouchPress(pointer, pressed, released); + + if (!released) + { + ProcessMove(pointer); + ProcessDrag(pointer); + } + else + RemovePointerData(pointer); + } + } + + protected void ProcessTouchPress(PointerEventData pointerEvent, bool pressed, bool released) + { + var currentOverGo = pointerEvent.pointerCurrentRaycast.gameObject; + + // PointerDown notification + if (pressed) + { + pointerEvent.eligibleForClick = true; + pointerEvent.delta = Vector2.zero; + pointerEvent.dragging = false; + pointerEvent.useDragThreshold = true; + pointerEvent.pressPosition = pointerEvent.position; + pointerEvent.pointerPressRaycast = pointerEvent.pointerCurrentRaycast; + + DeselectIfSelectionChanged(currentOverGo, pointerEvent); + + if (pointerEvent.pointerEnter != currentOverGo) + { + // send a pointer enter to the touched element if it isn't the one to select... + HandlePointerExitAndEnter(pointerEvent, currentOverGo); + pointerEvent.pointerEnter = currentOverGo; + } + + // search for the control that will receive the press + // if we can't find a press handler set the press + // handler to be what would receive a click. + var newPressed = ExecuteEvents.ExecuteHierarchy(currentOverGo, pointerEvent, ExecuteEvents.pointerDownHandler); + + // didnt find a press handler... search for a click handler + if (newPressed == null) + newPressed = ExecuteEvents.GetEventHandler(currentOverGo); + + // Debug.Log("Pressed: " + newPressed); + + float time = Time.unscaledTime; + + if (newPressed == pointerEvent.lastPress) + { + var diffTime = time - pointerEvent.clickTime; + if (diffTime < 0.3f) + ++pointerEvent.clickCount; + else + pointerEvent.clickCount = 1; + + pointerEvent.clickTime = time; + } + else + { + pointerEvent.clickCount = 1; + } + + pointerEvent.pointerPress = newPressed; + pointerEvent.rawPointerPress = currentOverGo; + + pointerEvent.clickTime = time; + + // Save the drag handler as well + pointerEvent.pointerDrag = ExecuteEvents.GetEventHandler(currentOverGo); + + if (pointerEvent.pointerDrag != null) + ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.initializePotentialDrag); + } + + // PointerUp notification + if (released) + { + // Debug.Log("Executing pressup on: " + pointer.pointerPress); + ExecuteEvents.Execute(pointerEvent.pointerPress, pointerEvent, ExecuteEvents.pointerUpHandler); + + // Debug.Log("KeyCode: " + pointer.eventData.keyCode); + + // see if we mouse up on the same element that we clicked on... + var pointerUpHandler = ExecuteEvents.GetEventHandler(currentOverGo); + + // PointerClick and Drop events + if (pointerEvent.pointerPress == pointerUpHandler && pointerEvent.eligibleForClick) + { + ExecuteEvents.Execute(pointerEvent.pointerPress, pointerEvent, ExecuteEvents.pointerClickHandler); + } + else if (pointerEvent.pointerDrag != null && pointerEvent.dragging) + { + ExecuteEvents.ExecuteHierarchy(currentOverGo, pointerEvent, ExecuteEvents.dropHandler); + } + + pointerEvent.eligibleForClick = false; + pointerEvent.pointerPress = null; + pointerEvent.rawPointerPress = null; + + if (pointerEvent.pointerDrag != null && pointerEvent.dragging) + ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.endDragHandler); + + pointerEvent.dragging = false; + pointerEvent.pointerDrag = null; + + if (pointerEvent.pointerDrag != null) + ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.endDragHandler); + + pointerEvent.pointerDrag = null; + + // send exit events as we need to simulate this on touch up on touch device + ExecuteEvents.ExecuteHierarchy(pointerEvent.pointerEnter, pointerEvent, ExecuteEvents.pointerExitHandler); + pointerEvent.pointerEnter = null; + } + } + + public override void DeactivateModule() + { + base.DeactivateModule(); + ClearSelection(); + } + + public override string ToString() + { + var sb = new StringBuilder(); + sb.AppendLine(UseFakeInput() ? "Input: Faked" : "Input: Touch"); + if (UseFakeInput()) + { + var pointerData = GetLastPointerEventData(kMouseLeftId); + if (pointerData != null) + sb.AppendLine(pointerData.ToString()); + } + else + { + foreach (var pointerEventData in m_PointerData) + sb.AppendLine(pointerEventData.ToString()); + } + return sb.ToString(); + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/TouchInputModule.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/TouchInputModule.cs.meta new file mode 100644 index 0000000..facfc33 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/TouchInputModule.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 27cc0457fb3bcbe4eb6038275fbdde36 +timeCreated: 1602119378 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/MoveDirection.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/MoveDirection.cs new file mode 100644 index 0000000..4f4147c --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/MoveDirection.cs @@ -0,0 +1,11 @@ +namespace UnityEngine.EventSystems +{ + public enum MoveDirection + { + Left, + Up, + Right, + Down, + None + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/MoveDirection.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/MoveDirection.cs.meta new file mode 100644 index 0000000..ba67175 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/MoveDirection.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: a1de2f5af1cc8aa4aa68afe78b9c671e +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/RaycastResult.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/RaycastResult.cs new file mode 100644 index 0000000..12a339b --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/RaycastResult.cs @@ -0,0 +1,64 @@ +namespace UnityEngine.EventSystems +{ + public struct RaycastResult + { + private GameObject m_GameObject; // Game object hit by the raycast + + public GameObject gameObject + { + get { return m_GameObject; } + set { m_GameObject = value; } + } + + public BaseRaycaster module; // Event system that hit this object + public float distance; // The distance from the origin this hit was. + public float index; // The index this element is in the raycastList (used for sorting) + public int depth; + public int sortingLayer; + public int sortingOrder; + // World-space position where a ray cast into the screen hits something + public Vector3 worldPosition; + // World-space normal where a ray cast into the screen hits something + public Vector3 worldNormal; + + public Vector2 screenPosition; + + public bool isValid + { + get { return module != null && gameObject != null; } + } + + public void Clear() + { + gameObject = null; + module = null; + distance = 0; + index = 0; + depth = 0; + sortingLayer = 0; + sortingOrder = 0; + worldNormal = Vector3.up; + worldPosition = Vector3.zero; + screenPosition = Vector2.zero; + } + + public override string ToString() + { + if (!isValid) + return ""; + + return "Name: " + gameObject + "\n" + + "module: " + module + "\n" + + "distance: " + distance + "\n" + + "index: " + index + "\n" + + "depth: " + depth + "\n" + + "worldNormal: " + worldNormal + "\n" + + "worldPosition: " + worldPosition + "\n" + + "screenPosition: " + screenPosition + "\n" + + "module.sortOrderPriority: " + module.sortOrderPriority + "\n" + + "module.renderOrderPriority: " + module.renderOrderPriority + "\n" + + "sortingLayer: " + sortingLayer + "\n" + + "sortingOrder: " + sortingOrder; + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/RaycastResult.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/RaycastResult.cs.meta new file mode 100644 index 0000000..34d3799 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/RaycastResult.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 500a96364b902574fb3486a1c93591b3 +timeCreated: 1602119378 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/RaycasterManager.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/RaycasterManager.cs new file mode 100644 index 0000000..c3480b4 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/RaycasterManager.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; + +namespace UnityEngine.EventSystems +{ + internal static class RaycasterManager + { + private static readonly List s_Raycasters = new List(); + + public static void AddRaycaster(BaseRaycaster baseRaycaster) + { + if (s_Raycasters.Contains(baseRaycaster)) + return; + + s_Raycasters.Add(baseRaycaster); + } + + public static List GetRaycasters() + { + return s_Raycasters; + } + + public static void RemoveRaycasters(BaseRaycaster baseRaycaster) + { + if (!s_Raycasters.Contains(baseRaycaster)) + return; + s_Raycasters.Remove(baseRaycaster); + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/RaycasterManager.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/RaycasterManager.cs.meta new file mode 100644 index 0000000..9351151 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/RaycasterManager.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b028797ae6e79fd48b667fede5f64ca9 +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters.meta new file mode 100644 index 0000000..104ea1f --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: c57aabd138e5b164ebd06107a0c19483 +folderAsset: yes +timeCreated: 1602119280 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/BaseRaycaster.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/BaseRaycaster.cs new file mode 100644 index 0000000..f9a8558 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/BaseRaycaster.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; + +namespace UnityEngine.EventSystems +{ + public abstract class BaseRaycaster : UIBehaviour + { + public abstract void Raycast(PointerEventData eventData, List resultAppendList); + public abstract Camera eventCamera { get; } + + [Obsolete("Please use sortOrderPriority and renderOrderPriority", false)] + public virtual int priority + { + get { return 0; } + } + + public virtual int sortOrderPriority + { + get { return int.MinValue; } + } + + public virtual int renderOrderPriority + { + get { return int.MinValue; } + } + + public override string ToString() + { + return "Name: " + gameObject + "\n" + + "eventCamera: " + eventCamera + "\n" + + "sortOrderPriority: " + sortOrderPriority + "\n" + + "renderOrderPriority: " + renderOrderPriority; + } + + protected override void OnEnable() + { + base.OnEnable(); + RaycasterManager.AddRaycaster(this); + } + + protected override void OnDisable() + { + RaycasterManager.RemoveRaycasters(this); + base.OnDisable(); + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/BaseRaycaster.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/BaseRaycaster.cs.meta new file mode 100644 index 0000000..eb8b89a --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/BaseRaycaster.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 89c5c6ccaa917c94a864388cc962e706 +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/Physics2DRaycaster.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/Physics2DRaycaster.cs new file mode 100644 index 0000000..783cf95 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/Physics2DRaycaster.cs @@ -0,0 +1,53 @@ +using System.Collections.Generic; +using UnityEngine.UI; + +namespace UnityEngine.EventSystems +{ + /// + /// Simple event system using physics raycasts. + /// + [AddComponentMenu("Event/Physics 2D Raycaster")] + [RequireComponent(typeof(Camera))] + public class Physics2DRaycaster : PhysicsRaycaster + { + protected Physics2DRaycaster() + {} + + public override void Raycast(PointerEventData eventData, List resultAppendList) + { + if (eventCamera == null) + return; + + Ray ray; + float distanceToClipPlane; + ComputeRayAndDistance(eventData, out ray, out distanceToClipPlane); + + if (ReflectionMethodsCache.Singleton.getRayIntersectionAll == null) + return; + + var hits = ReflectionMethodsCache.Singleton.getRayIntersectionAll(ray, distanceToClipPlane, finalEventMask); + + if (hits.Length != 0) + { + for (int b = 0, bmax = hits.Length; b < bmax; ++b) + { + var sr = hits[b].collider.gameObject.GetComponent(); + + var result = new RaycastResult + { + gameObject = hits[b].collider.gameObject, + module = this, + distance = Vector3.Distance(eventCamera.transform.position, hits[b].point), + worldPosition = hits[b].point, + worldNormal = hits[b].normal, + screenPosition = eventData.position, + index = resultAppendList.Count, + sortingLayer = sr != null ? sr.sortingLayerID : 0, + sortingOrder = sr != null ? sr.sortingOrder : 0 + }; + resultAppendList.Add(result); + } + } + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/Physics2DRaycaster.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/Physics2DRaycaster.cs.meta new file mode 100644 index 0000000..828be37 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/Physics2DRaycaster.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 055a0cdd9d5d3e0489f854f7bdf22ded +timeCreated: 1602119377 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/PhysicsRaycaster.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/PhysicsRaycaster.cs new file mode 100644 index 0000000..2b4bea3 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/PhysicsRaycaster.cs @@ -0,0 +1,114 @@ +using System.Collections.Generic; +using UnityEngine.UI; + +namespace UnityEngine.EventSystems +{ + /// + /// Simple event system using physics raycasts. + /// + [AddComponentMenu("Event/Physics Raycaster")] + [RequireComponent(typeof(Camera))] + public class PhysicsRaycaster : BaseRaycaster + { + /// + /// Const to use for clarity when no event mask is set + /// + protected const int kNoEventMaskSet = -1; + + protected Camera m_EventCamera; + + /// + /// Layer mask used to filter events. Always combined with the camera's culling mask if a camera is used. + /// + [SerializeField] + protected LayerMask m_EventMask = kNoEventMaskSet; + + protected PhysicsRaycaster() + {} + + public override Camera eventCamera + { + get + { + if (m_EventCamera == null) + m_EventCamera = GetComponent(); + return m_EventCamera ?? Camera.main; + } + } + + + /// + /// Depth used to determine the order of event processing. + /// + public virtual int depth + { + get { return (eventCamera != null) ? (int)eventCamera.depth : 0xFFFFFF; } + } + + /// + /// Event mask used to determine which objects will receive events. + /// + public int finalEventMask + { + get { return (eventCamera != null) ? eventCamera.cullingMask & m_EventMask : kNoEventMaskSet; } + } + + /// + /// Layer mask used to filter events. Always combined with the camera's culling mask if a camera is used. + /// + public LayerMask eventMask + { + get { return m_EventMask; } + set { m_EventMask = value; } + } + + protected void ComputeRayAndDistance(PointerEventData eventData, out Ray ray, out float distanceToClipPlane) + { + ray = eventCamera.ScreenPointToRay(eventData.position); + // compensate far plane distance - see MouseEvents.cs + float projectionDirection = ray.direction.z; + distanceToClipPlane = Mathf.Approximately(0.0f, projectionDirection) + ? Mathf.Infinity + : Mathf.Abs((eventCamera.farClipPlane - eventCamera.nearClipPlane) / projectionDirection); + } + + public override void Raycast(PointerEventData eventData, List resultAppendList) + { + // Cull ray casts that are outside of the view rect. (case 636595) + if (eventCamera == null || !eventCamera.pixelRect.Contains(eventData.position)) + return; + + Ray ray; + float distanceToClipPlane; + ComputeRayAndDistance(eventData, out ray, out distanceToClipPlane); + + if (ReflectionMethodsCache.Singleton.raycast3DAll == null) + return; + + var hits = ReflectionMethodsCache.Singleton.raycast3DAll(ray, distanceToClipPlane, finalEventMask); + + if (hits.Length > 1) + System.Array.Sort(hits, (r1, r2) => r1.distance.CompareTo(r2.distance)); + + if (hits.Length != 0) + { + for (int b = 0, bmax = hits.Length; b < bmax; ++b) + { + var result = new RaycastResult + { + gameObject = hits[b].collider.gameObject, + module = this, + distance = hits[b].distance, + worldPosition = hits[b].point, + worldNormal = hits[b].normal, + screenPosition = eventData.position, + index = resultAppendList.Count, + sortingLayer = 0, + sortingOrder = 0 + }; + resultAppendList.Add(result); + } + } + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/PhysicsRaycaster.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/PhysicsRaycaster.cs.meta new file mode 100644 index 0000000..848c302 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/PhysicsRaycaster.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b2bb18305a46ea44686ad8cdffbb3a58 +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/UIBehaviour.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/UIBehaviour.cs new file mode 100644 index 0000000..523fe50 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/UIBehaviour.cs @@ -0,0 +1,59 @@ +namespace UnityEngine.EventSystems +{ + public abstract class UIBehaviour : MonoBehaviour + { + protected virtual void Awake() + {} + + protected virtual void OnEnable() + {} + + protected virtual void Start() + {} + + protected virtual void OnDisable() + {} + + protected virtual void OnDestroy() + {} + + public virtual bool IsActive() + { + return isActiveAndEnabled; + } + +#if UNITY_EDITOR + protected virtual void OnValidate() + {} + + protected virtual void Reset() + {} +#endif + + protected virtual void OnRectTransformDimensionsChange() + {} + + protected virtual void OnBeforeTransformParentChanged() + {} + + protected virtual void OnTransformParentChanged() + {} + + protected virtual void OnDidApplyAnimationProperties() + {} + + protected virtual void OnCanvasGroupChanged() + {} + + protected virtual void OnCanvasHierarchyChanged() + {} + + public bool IsDestroyed() + { + // Workaround for Unity native side of the object + // having been destroyed but accessing via interface + // won't call the overloaded == + return this == null; + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/UIBehaviour.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/UIBehaviour.cs.meta new file mode 100644 index 0000000..8a8845a --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/UIBehaviour.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: c17b5e621296cc74ca0fdc04a3cb30d0 +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI.meta b/Assets/uGUI-2017.1/UnityEngine.UI/UI.meta new file mode 100644 index 0000000..4764843 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d5f4eaf4348fe954f9122f4bcf79bb50 +folderAsset: yes +timeCreated: 1602119280 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Animation.meta b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Animation.meta new file mode 100644 index 0000000..5b44e55 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Animation.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e00b01f6bce849742b17da47682197e4 +folderAsset: yes +timeCreated: 1602119280 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Animation/CoroutineTween.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Animation/CoroutineTween.cs new file mode 100644 index 0000000..8b15b3c --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Animation/CoroutineTween.cs @@ -0,0 +1,244 @@ +using System.Collections; +using UnityEngine.Events; + +namespace UnityEngine.UI.CoroutineTween +{ + // Base interface for tweeners, + // using an interface instead of + // an abstract class as we want the + // tweens to be structs. + internal interface ITweenValue + { + void TweenValue(float floatPercentage); + bool ignoreTimeScale { get; } + float duration { get; } + bool ValidTarget(); + } + + // Color tween class, receives the + // TweenValue callback and then sets + // the value on the target. + internal struct ColorTween : ITweenValue + { + public enum ColorTweenMode + { + All, + RGB, + Alpha + } + + public class ColorTweenCallback : UnityEvent {} + + private ColorTweenCallback m_Target; + private Color m_StartColor; + private Color m_TargetColor; + private ColorTweenMode m_TweenMode; + + private float m_Duration; + private bool m_IgnoreTimeScale; + + public Color startColor + { + get { return m_StartColor; } + set { m_StartColor = value; } + } + + public Color targetColor + { + get { return m_TargetColor; } + set { m_TargetColor = value; } + } + + public ColorTweenMode tweenMode + { + get { return m_TweenMode; } + set { m_TweenMode = value; } + } + + public float duration + { + get { return m_Duration; } + set { m_Duration = value; } + } + + public bool ignoreTimeScale + { + get { return m_IgnoreTimeScale; } + set { m_IgnoreTimeScale = value; } + } + + public void TweenValue(float floatPercentage) + { + if (!ValidTarget()) + return; + + var newColor = Color.Lerp(m_StartColor, m_TargetColor, floatPercentage); + + if (m_TweenMode == ColorTweenMode.Alpha) + { + newColor.r = m_StartColor.r; + newColor.g = m_StartColor.g; + newColor.b = m_StartColor.b; + } + else if (m_TweenMode == ColorTweenMode.RGB) + { + newColor.a = m_StartColor.a; + } + m_Target.Invoke(newColor); + } + + public void AddOnChangedCallback(UnityAction callback) + { + if (m_Target == null) + m_Target = new ColorTweenCallback(); + + m_Target.AddListener(callback); + } + + public bool GetIgnoreTimescale() + { + return m_IgnoreTimeScale; + } + + public float GetDuration() + { + return m_Duration; + } + + public bool ValidTarget() + { + return m_Target != null; + } + } + + // Float tween class, receives the + // TweenValue callback and then sets + // the value on the target. + internal struct FloatTween : ITweenValue + { + public class FloatTweenCallback : UnityEvent {} + + private FloatTweenCallback m_Target; + private float m_StartValue; + private float m_TargetValue; + + private float m_Duration; + private bool m_IgnoreTimeScale; + + public float startValue + { + get { return m_StartValue; } + set { m_StartValue = value; } + } + + public float targetValue + { + get { return m_TargetValue; } + set { m_TargetValue = value; } + } + + public float duration + { + get { return m_Duration; } + set { m_Duration = value; } + } + + public bool ignoreTimeScale + { + get { return m_IgnoreTimeScale; } + set { m_IgnoreTimeScale = value; } + } + + public void TweenValue(float floatPercentage) + { + if (!ValidTarget()) + return; + + var newValue = Mathf.Lerp(m_StartValue, m_TargetValue, floatPercentage); + m_Target.Invoke(newValue); + } + + public void AddOnChangedCallback(UnityAction callback) + { + if (m_Target == null) + m_Target = new FloatTweenCallback(); + + m_Target.AddListener(callback); + } + + public bool GetIgnoreTimescale() + { + return m_IgnoreTimeScale; + } + + public float GetDuration() + { + return m_Duration; + } + + public bool ValidTarget() + { + return m_Target != null; + } + } + + // Tween runner, executes the given tween. + // The coroutine will live within the given + // behaviour container. + internal class TweenRunner where T : struct, ITweenValue + { + protected MonoBehaviour m_CoroutineContainer; + protected IEnumerator m_Tween; + + // utility function for starting the tween + private static IEnumerator Start(T tweenInfo) + { + if (!tweenInfo.ValidTarget()) + yield break; + + var elapsedTime = 0.0f; + while (elapsedTime < tweenInfo.duration) + { + elapsedTime += tweenInfo.ignoreTimeScale ? Time.unscaledDeltaTime : Time.deltaTime; + var percentage = Mathf.Clamp01(elapsedTime / tweenInfo.duration); + tweenInfo.TweenValue(percentage); + yield return null; + } + tweenInfo.TweenValue(1.0f); + } + + public void Init(MonoBehaviour coroutineContainer) + { + m_CoroutineContainer = coroutineContainer; + } + + public void StartTween(T info) + { + if (m_CoroutineContainer == null) + { + Debug.LogWarning("Coroutine container not configured... did you forget to call Init?"); + return; + } + + StopTween(); + + if (!m_CoroutineContainer.gameObject.activeInHierarchy) + { + info.TweenValue(1.0f); + return; + } + + m_Tween = Start(info); + m_CoroutineContainer.StartCoroutine(m_Tween); + } + + public void StopTween() + { + if (m_Tween != null) + { + m_CoroutineContainer.StopCoroutine(m_Tween); + m_Tween = null; + } + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Animation/CoroutineTween.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Animation/CoroutineTween.cs.meta new file mode 100644 index 0000000..9983570 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Animation/CoroutineTween.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: efe72eb8cde345840879f501ccbaede1 +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core.meta b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core.meta new file mode 100644 index 0000000..5c6fab8 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: a003943df2ce88d4fb12b21661fe21ab +folderAsset: yes +timeCreated: 1602119280 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/AnimationTriggers.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/AnimationTriggers.cs new file mode 100644 index 0000000..e42871b --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/AnimationTriggers.cs @@ -0,0 +1,36 @@ +using System; +using UnityEngine.Serialization; + +namespace UnityEngine.UI +{ + [Serializable] + public class AnimationTriggers + { + private const string kDefaultNormalAnimName = "Normal"; + private const string kDefaultSelectedAnimName = "Highlighted"; + private const string kDefaultPressedAnimName = "Pressed"; + private const string kDefaultDisabledAnimName = "Disabled"; + + [FormerlySerializedAs("normalTrigger")] + [SerializeField] + private string m_NormalTrigger = kDefaultNormalAnimName; + + [FormerlySerializedAs("highlightedTrigger")] + [FormerlySerializedAs("m_SelectedTrigger")] + [SerializeField] + private string m_HighlightedTrigger = kDefaultSelectedAnimName; + + [FormerlySerializedAs("pressedTrigger")] + [SerializeField] + private string m_PressedTrigger = kDefaultPressedAnimName; + + [FormerlySerializedAs("disabledTrigger")] + [SerializeField] + private string m_DisabledTrigger = kDefaultDisabledAnimName; + + public string normalTrigger { get { return m_NormalTrigger; } set { m_NormalTrigger = value; } } + public string highlightedTrigger { get { return m_HighlightedTrigger; } set { m_HighlightedTrigger = value; } } + public string pressedTrigger { get { return m_PressedTrigger; } set { m_PressedTrigger = value; } } + public string disabledTrigger { get { return m_DisabledTrigger; } set { m_DisabledTrigger = value; } } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/AnimationTriggers.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/AnimationTriggers.cs.meta new file mode 100644 index 0000000..3ce27e0 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/AnimationTriggers.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: c5ef5ca89cbc4644cae2997e4a851944 +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Button.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Button.cs new file mode 100644 index 0000000..8be5532 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Button.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections; +using UnityEngine.Events; +using UnityEngine.EventSystems; +using UnityEngine.Serialization; + +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 + { + [Serializable] + public class ButtonClickedEvent : UnityEvent {} + + // Event delegates triggered on click. + [FormerlySerializedAs("onClick")] + [SerializeField] + private ButtonClickedEvent m_OnClick = new ButtonClickedEvent(); + + protected Button() + {} + + public ButtonClickedEvent onClick + { + get { return m_OnClick; } + set { m_OnClick = value; } + } + + private void Press() + { + if (!IsActive() || !IsInteractable()) + return; + + UISystemProfilerApi.AddMarker("Button.onClick", this); + m_OnClick.Invoke(); + } + + // Trigger all registered callbacks. + public virtual void OnPointerClick(PointerEventData eventData) + { + if (eventData.button != PointerEventData.InputButton.Left) + return; + + Press(); + } + + public virtual void OnSubmit(BaseEventData eventData) + { + Press(); + + // if we get set disabled during the press + // don't run the coroutine. + if (!IsActive() || !IsInteractable()) + return; + + DoStateTransition(SelectionState.Pressed, false); + StartCoroutine(OnFinishSubmit()); + } + + private IEnumerator OnFinishSubmit() + { + var fadeTime = colors.fadeDuration; + var elapsedTime = 0f; + + while (elapsedTime < fadeTime) + { + elapsedTime += Time.unscaledDeltaTime; + yield return null; + } + + DoStateTransition(currentSelectionState, false); + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Button.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Button.cs.meta new file mode 100644 index 0000000..d34a2d3 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Button.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b55754d97ca63cd4dbfeea25c980c065 +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs new file mode 100644 index 0000000..bc7263b --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs @@ -0,0 +1,275 @@ +using System; +using System.Collections.Generic; +using UnityEngine.UI.Collections; + +namespace UnityEngine.UI +{ + public enum CanvasUpdate + { + Prelayout = 0, + Layout = 1, + PostLayout = 2, + PreRender = 3, + LatePreRender = 4, + MaxUpdateValue = 5 + } + + public interface ICanvasElement + { + void Rebuild(CanvasUpdate executing); + Transform transform { get; } + void LayoutComplete(); + void GraphicUpdateComplete(); + // due to unity overriding null check + // we need this as something may not be null + // but may be destroyed + bool IsDestroyed(); + } + + public class CanvasUpdateRegistry + { + private static CanvasUpdateRegistry s_Instance; + + private bool m_PerformingLayoutUpdate; + private bool m_PerformingGraphicUpdate; + + private readonly IndexedSet m_LayoutRebuildQueue = new IndexedSet(); + private readonly IndexedSet m_GraphicRebuildQueue = new IndexedSet(); + + protected CanvasUpdateRegistry() + { + Canvas.willRenderCanvases += PerformUpdate; + } + + public static CanvasUpdateRegistry instance + { + get + { + if (s_Instance == null) + s_Instance = new CanvasUpdateRegistry(); + return s_Instance; + } + } + + private bool ObjectValidForUpdate(ICanvasElement element) + { + var valid = element != null; + + var isUnityObject = element is Object; + if (isUnityObject) + valid = (element as Object) != null; //Here we make use of the overloaded UnityEngine.Object == null, that checks if the native object is alive. + + return valid; + } + + private void CleanInvalidItems() + { + // So MB's override the == operator for null equality, which checks + // if they are destroyed. This is fine if you are looking at a concrete + // mb, but in this case we are looking at a list of ICanvasElement + // this won't forward the == operator to the MB, but just check if the + // interface is null. IsDestroyed will return if the backend is destroyed. + + for (int i = m_LayoutRebuildQueue.Count - 1; i >= 0; --i) + { + var item = m_LayoutRebuildQueue[i]; + if (item == null) + { + m_LayoutRebuildQueue.RemoveAt(i); + continue; + } + + if (item.IsDestroyed()) + { + m_LayoutRebuildQueue.RemoveAt(i); + item.LayoutComplete(); + } + } + + for (int i = m_GraphicRebuildQueue.Count - 1; i >= 0; --i) + { + var item = m_GraphicRebuildQueue[i]; + if (item == null) + { + m_GraphicRebuildQueue.RemoveAt(i); + continue; + } + + if (item.IsDestroyed()) + { + m_GraphicRebuildQueue.RemoveAt(i); + item.GraphicUpdateComplete(); + } + } + } + + private static readonly Comparison s_SortLayoutFunction = SortLayoutList; + private void PerformUpdate() + { + UISystemProfilerApi.BeginSample(UISystemProfilerApi.SampleType.Layout); + CleanInvalidItems(); + + m_PerformingLayoutUpdate = true; + + m_LayoutRebuildQueue.Sort(s_SortLayoutFunction); + for (int i = 0; i <= (int)CanvasUpdate.PostLayout; i++) + { + for (int j = 0; j < m_LayoutRebuildQueue.Count; j++) + { + var rebuild = instance.m_LayoutRebuildQueue[j]; + try + { + if (ObjectValidForUpdate(rebuild)) + rebuild.Rebuild((CanvasUpdate)i); + } + catch (Exception e) + { + Debug.LogException(e, rebuild.transform); + } + } + } + + for (int i = 0; i < m_LayoutRebuildQueue.Count; ++i) + m_LayoutRebuildQueue[i].LayoutComplete(); + + instance.m_LayoutRebuildQueue.Clear(); + m_PerformingLayoutUpdate = false; + + // now layout is complete do culling... + ClipperRegistry.instance.Cull(); + + m_PerformingGraphicUpdate = true; + for (var i = (int)CanvasUpdate.PreRender; i < (int)CanvasUpdate.MaxUpdateValue; i++) + { + for (var k = 0; k < instance.m_GraphicRebuildQueue.Count; k++) + { + try + { + var element = instance.m_GraphicRebuildQueue[k]; + if (ObjectValidForUpdate(element)) + element.Rebuild((CanvasUpdate)i); + } + catch (Exception e) + { + Debug.LogException(e, instance.m_GraphicRebuildQueue[k].transform); + } + } + } + + for (int i = 0; i < m_GraphicRebuildQueue.Count; ++i) + m_GraphicRebuildQueue[i].GraphicUpdateComplete(); + + instance.m_GraphicRebuildQueue.Clear(); + m_PerformingGraphicUpdate = false; + UISystemProfilerApi.EndSample(UISystemProfilerApi.SampleType.Layout); + } + + private static int ParentCount(Transform child) + { + if (child == null) + return 0; + + var parent = child.parent; + int count = 0; + while (parent != null) + { + count++; + parent = parent.parent; + } + return count; + } + + private static int SortLayoutList(ICanvasElement x, ICanvasElement y) + { + Transform t1 = x.transform; + Transform t2 = y.transform; + + return ParentCount(t1) - ParentCount(t2); + } + + public static void RegisterCanvasElementForLayoutRebuild(ICanvasElement element) + { + instance.InternalRegisterCanvasElementForLayoutRebuild(element); + } + + public static bool TryRegisterCanvasElementForLayoutRebuild(ICanvasElement element) + { + return instance.InternalRegisterCanvasElementForLayoutRebuild(element); + } + + private bool InternalRegisterCanvasElementForLayoutRebuild(ICanvasElement element) + { + if (m_LayoutRebuildQueue.Contains(element)) + return false; + + /* TODO: this likely should be here but causes the error to show just resizing the game view (case 739376) + if (m_PerformingLayoutUpdate) + { + Debug.LogError(string.Format("Trying to add {0} for layout rebuild while we are already inside a layout rebuild loop. This is not supported.", element)); + return false; + }*/ + + return m_LayoutRebuildQueue.AddUnique(element); + } + + public static void RegisterCanvasElementForGraphicRebuild(ICanvasElement element) + { + instance.InternalRegisterCanvasElementForGraphicRebuild(element); + } + + public static bool TryRegisterCanvasElementForGraphicRebuild(ICanvasElement element) + { + return instance.InternalRegisterCanvasElementForGraphicRebuild(element); + } + + private bool InternalRegisterCanvasElementForGraphicRebuild(ICanvasElement element) + { + if (m_PerformingGraphicUpdate) + { + Debug.LogError(string.Format("Trying to add {0} for graphic rebuild while we are already inside a graphic rebuild loop. This is not supported.", element)); + return false; + } + + return m_GraphicRebuildQueue.AddUnique(element); + } + + public static void UnRegisterCanvasElementForRebuild(ICanvasElement element) + { + instance.InternalUnRegisterCanvasElementForLayoutRebuild(element); + instance.InternalUnRegisterCanvasElementForGraphicRebuild(element); + } + + private void InternalUnRegisterCanvasElementForLayoutRebuild(ICanvasElement element) + { + if (m_PerformingLayoutUpdate) + { + Debug.LogError(string.Format("Trying to remove {0} from rebuild list while we are already inside a rebuild loop. This is not supported.", element)); + return; + } + + element.LayoutComplete(); + instance.m_LayoutRebuildQueue.Remove(element); + } + + private void InternalUnRegisterCanvasElementForGraphicRebuild(ICanvasElement element) + { + if (m_PerformingGraphicUpdate) + { + Debug.LogError(string.Format("Trying to remove {0} from rebuild list while we are already inside a rebuild loop. This is not supported.", element)); + return; + } + element.GraphicUpdateComplete(); + instance.m_GraphicRebuildQueue.Remove(element); + } + + public static bool IsRebuildingLayout() + { + return instance.m_PerformingLayoutUpdate; + } + + public static bool IsRebuildingGraphics() + { + return instance.m_PerformingGraphicUpdate; + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs.meta new file mode 100644 index 0000000..be77e1d --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b607eb8b4c72f944c9fda5d106491067 +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/ColorBlock.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/ColorBlock.cs new file mode 100644 index 0000000..c78d617 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/ColorBlock.cs @@ -0,0 +1,91 @@ +using System; +using UnityEngine.Serialization; + +namespace UnityEngine.UI +{ + [Serializable] + public struct ColorBlock : IEquatable + { + [FormerlySerializedAs("normalColor")] + [SerializeField] + private Color m_NormalColor; + + [FormerlySerializedAs("highlightedColor")] + [FormerlySerializedAs("m_SelectedColor")] + [SerializeField] + private Color m_HighlightedColor; + + [FormerlySerializedAs("pressedColor")] + [SerializeField] + private Color m_PressedColor; + + [FormerlySerializedAs("disabledColor")] + [SerializeField] + private Color m_DisabledColor; + + [Range(1, 5)] + [SerializeField] + private float m_ColorMultiplier; + + [FormerlySerializedAs("fadeDuration")] + [SerializeField] + private float m_FadeDuration; + + public Color normalColor { get { return m_NormalColor; } set { m_NormalColor = value; } } + public Color highlightedColor { get { return m_HighlightedColor; } set { m_HighlightedColor = value; } } + public Color pressedColor { get { return m_PressedColor; } set { m_PressedColor = value; } } + public Color disabledColor { get { return m_DisabledColor; } set { m_DisabledColor = value; } } + public float colorMultiplier { get { return m_ColorMultiplier; } set { m_ColorMultiplier = value; } } + public float fadeDuration { get { return m_FadeDuration; } set { m_FadeDuration = value; } } + + public static ColorBlock defaultColorBlock + { + get + { + var c = new ColorBlock + { + m_NormalColor = new Color32(255, 255, 255, 255), + m_HighlightedColor = new Color32(245, 245, 245, 255), + m_PressedColor = new Color32(200, 200, 200, 255), + m_DisabledColor = new Color32(200, 200, 200, 128), + colorMultiplier = 1.0f, + fadeDuration = 0.1f + }; + return c; + } + } + + public override bool Equals(object obj) + { + if (!(obj is ColorBlock)) + return false; + + return Equals((ColorBlock)obj); + } + + public bool Equals(ColorBlock other) + { + return normalColor == other.normalColor && + highlightedColor == other.highlightedColor && + pressedColor == other.pressedColor && + disabledColor == other.disabledColor && + colorMultiplier == other.colorMultiplier && + fadeDuration == other.fadeDuration; + } + + public static bool operator==(ColorBlock point1, ColorBlock point2) + { + return point1.Equals(point2); + } + + public static bool operator!=(ColorBlock point1, ColorBlock point2) + { + return !point1.Equals(point2); + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/ColorBlock.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/ColorBlock.cs.meta new file mode 100644 index 0000000..6c616c3 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/ColorBlock.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 5c8834cada9a547419a323569ac63c64 +timeCreated: 1602119378 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling.meta b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling.meta new file mode 100644 index 0000000..2b86263 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 2f77b3d02da9eb145be1dfc4c8684a80 +folderAsset: yes +timeCreated: 1602119280 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/ClipperRegistry.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/ClipperRegistry.cs new file mode 100644 index 0000000..ea7f527 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/ClipperRegistry.cs @@ -0,0 +1,50 @@ +using System.Collections.Generic; +using UnityEngine.UI.Collections; + +namespace UnityEngine.UI +{ + public class ClipperRegistry + { + static ClipperRegistry s_Instance; + + readonly IndexedSet m_Clippers = new IndexedSet(); + + protected ClipperRegistry() + { + // This is needed for AOT platforms. Without it the compile doesn't get the definition of the Dictionarys +#pragma warning disable 168 + Dictionary emptyIClipperDic; +#pragma warning restore 168 + } + + public static ClipperRegistry instance + { + get + { + if (s_Instance == null) + s_Instance = new ClipperRegistry(); + return s_Instance; + } + } + + public void Cull() + { + for (var i = 0; i < m_Clippers.Count; ++i) + { + m_Clippers[i].PerformClipping(); + } + } + + public static void Register(IClipper c) + { + if (c == null) + return; + instance.m_Clippers.AddUnique(c); + } + + public static void Unregister(IClipper c) + { + instance.m_Clippers.Remove(c); + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/ClipperRegistry.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/ClipperRegistry.cs.meta new file mode 100644 index 0000000..32995ae --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/ClipperRegistry.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b494fa40405522d49af6bca6e68e4ba6 +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/Clipping.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/Clipping.cs new file mode 100644 index 0000000..7707ecf --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/Clipping.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; + +namespace UnityEngine.UI +{ + public static class Clipping + { + public static Rect FindCullAndClipWorldRect(List rectMaskParents, out bool validRect) + { + if (rectMaskParents.Count == 0) + { + validRect = false; + return new Rect(); + } + + var compoundRect = rectMaskParents[0].canvasRect; + for (var i = 0; i < rectMaskParents.Count; ++i) + compoundRect = RectIntersect(compoundRect, rectMaskParents[i].canvasRect); + + var cull = compoundRect.width <= 0 || compoundRect.height <= 0; + if (cull) + { + validRect = false; + return new Rect(); + } + + Vector3 point1 = new Vector3(compoundRect.x, compoundRect.y, 0.0f); + Vector3 point2 = new Vector3(compoundRect.x + compoundRect.width, compoundRect.y + compoundRect.height, 0.0f); + validRect = true; + return new Rect(point1.x, point1.y, point2.x - point1.x, point2.y - point1.y); + } + + private static Rect RectIntersect(Rect a, Rect b) + { + float xMin = Mathf.Max(a.x, b.x); + float xMax = Mathf.Min(a.x + a.width, b.x + b.width); + float yMin = Mathf.Max(a.y, b.y); + float yMax = Mathf.Min(a.y + a.height, b.y + b.height); + if (xMax >= xMin && yMax >= yMin) + return new Rect(xMin, yMin, xMax - xMin, yMax - yMin); + return new Rect(0f, 0f, 0f, 0f); + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/Clipping.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/Clipping.cs.meta new file mode 100644 index 0000000..698e06f --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/Clipping.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 88fc11e9a11bf1941abc08b9ed323b6f +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/IClipRegion.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/IClipRegion.cs new file mode 100644 index 0000000..4593f17 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/IClipRegion.cs @@ -0,0 +1,16 @@ +namespace UnityEngine.UI +{ + public interface IClipper + { + void PerformClipping(); + } + + public interface IClippable + { + GameObject gameObject { get; } + void RecalculateClipping(); + RectTransform rectTransform { get; } + void Cull(Rect clipRect, bool validRect); + void SetClipRect(Rect value, bool validRect); + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/IClipRegion.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/IClipRegion.cs.meta new file mode 100644 index 0000000..1852869 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/IClipRegion.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: d395da6bc4c1e6f4b9521bb99b22f3b4 +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/RectangularVertexClipper.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/RectangularVertexClipper.cs new file mode 100644 index 0000000..6d12322 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/RectangularVertexClipper.cs @@ -0,0 +1,21 @@ +namespace UnityEngine.UI +{ + internal class RectangularVertexClipper + { + readonly Vector3[] m_WorldCorners = new Vector3[4]; + readonly Vector3[] m_CanvasCorners = new Vector3[4]; + + public Rect GetCanvasRect(RectTransform t, Canvas c) + { + if (c == null) + return new Rect(); + + t.GetWorldCorners(m_WorldCorners); + var canvasTransform = c.GetComponent(); + for (int i = 0; i < 4; ++i) + m_CanvasCorners[i] = canvasTransform.InverseTransformPoint(m_WorldCorners[i]); + + return new Rect(m_CanvasCorners[0].x, m_CanvasCorners[0].y, m_CanvasCorners[2].x - m_CanvasCorners[0].x, m_CanvasCorners[2].y - m_CanvasCorners[0].y); + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/RectangularVertexClipper.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/RectangularVertexClipper.cs.meta new file mode 100644 index 0000000..f33cd90 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/RectangularVertexClipper.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 545014a8997364a47b344095371a7332 +timeCreated: 1602119378 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/DefaultControls.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/DefaultControls.cs new file mode 100644 index 0000000..a22ff9a --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/DefaultControls.cs @@ -0,0 +1,581 @@ +using UnityEngine; +using System.Collections.Generic; + +namespace UnityEngine.UI +{ + public static class DefaultControls + { + public struct Resources + { + public Sprite standard; + public Sprite background; + public Sprite inputField; + public Sprite knob; + public Sprite checkmark; + public Sprite dropdown; + public Sprite mask; + } + + private const float kWidth = 160f; + private const float kThickHeight = 30f; + private const float kThinHeight = 20f; + private static Vector2 s_ThickElementSize = new Vector2(kWidth, kThickHeight); + private static Vector2 s_ThinElementSize = new Vector2(kWidth, kThinHeight); + private static Vector2 s_ImageElementSize = new Vector2(100f, 100f); + private static Color s_DefaultSelectableColor = new Color(1f, 1f, 1f, 1f); + private static Color s_PanelColor = new Color(1f, 1f, 1f, 0.392f); + private static Color s_TextColor = new Color(50f / 255f, 50f / 255f, 50f / 255f, 1f); + + // Helper methods at top + + private static GameObject CreateUIElementRoot(string name, Vector2 size) + { + GameObject child = new GameObject(name); + RectTransform rectTransform = child.AddComponent(); + rectTransform.sizeDelta = size; + return child; + } + + static GameObject CreateUIObject(string name, GameObject parent) + { + GameObject go = new GameObject(name); + go.AddComponent(); + SetParentAndAlign(go, parent); + return go; + } + + private static void SetDefaultTextValues(Text lbl) + { + // Set text values we want across UI elements in default controls. + // Don't set values which are the same as the default values for the Text component, + // since there's no point in that, and it's good to keep them as consistent as possible. + lbl.color = s_TextColor; + + // Reset() is not called when playing. We still want the default font to be assigned + lbl.AssignDefaultFont(); + } + + private static void SetDefaultColorTransitionValues(Selectable slider) + { + ColorBlock colors = slider.colors; + colors.highlightedColor = new Color(0.882f, 0.882f, 0.882f); + colors.pressedColor = new Color(0.698f, 0.698f, 0.698f); + colors.disabledColor = new Color(0.521f, 0.521f, 0.521f); + } + + private static void SetParentAndAlign(GameObject child, GameObject parent) + { + if (parent == null) + return; + + child.transform.SetParent(parent.transform, false); + SetLayerRecursively(child, parent.layer); + } + + private static void SetLayerRecursively(GameObject go, int layer) + { + go.layer = layer; + Transform t = go.transform; + for (int i = 0; i < t.childCount; i++) + SetLayerRecursively(t.GetChild(i).gameObject, layer); + } + + // Actual controls + + public static GameObject CreatePanel(Resources resources) + { + GameObject panelRoot = CreateUIElementRoot("Panel", s_ThickElementSize); + + // Set RectTransform to stretch + RectTransform rectTransform = panelRoot.GetComponent(); + rectTransform.anchorMin = Vector2.zero; + rectTransform.anchorMax = Vector2.one; + rectTransform.anchoredPosition = Vector2.zero; + rectTransform.sizeDelta = Vector2.zero; + + Image image = panelRoot.AddComponent(); + image.sprite = resources.background; + image.type = Image.Type.Sliced; + image.color = s_PanelColor; + + return panelRoot; + } + + public static GameObject CreateButton(Resources resources) + { + GameObject buttonRoot = CreateUIElementRoot("Button", s_ThickElementSize); + + GameObject childText = new GameObject("Text"); + childText.AddComponent(); + SetParentAndAlign(childText, buttonRoot); + + Image image = buttonRoot.AddComponent(); + image.sprite = resources.standard; + image.type = Image.Type.Sliced; + image.color = s_DefaultSelectableColor; + + Button bt = buttonRoot.AddComponent