From 00dae1bd426d892dff73a50f1c505afd1ac00a90 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 8 Oct 2020 09:50:33 +0800 Subject: +init --- Assets/Scenes.meta | 10 + Assets/Scenes/demo.unity | 600 +++++ Assets/Scenes/demo.unity.meta | 9 + Assets/Scripts.meta | 10 + Assets/Scripts/Test.cs | 16 + Assets/Scripts/Test.cs.meta | 13 + Assets/uGUI-2017.1.meta | 10 + Assets/uGUI-2017.1/Editor.meta | 10 + Assets/uGUI-2017.1/Editor/EventSystem.meta | 10 + .../Editor/EventSystem/EventSystemEditor.cs | 66 + .../Editor/EventSystem/EventSystemEditor.cs.meta | 13 + .../Editor/EventSystem/EventTriggerEditor.cs | 122 + .../Editor/EventSystem/EventTriggerEditor.cs.meta | 13 + Assets/uGUI-2017.1/Editor/UI.meta | 10 + .../Editor/UI/AspectRatioFitterEditor.cs | 29 + .../Editor/UI/AspectRatioFitterEditor.cs.meta | 13 + Assets/uGUI-2017.1/Editor/UI/AssemblyInfo.cs | 38 + Assets/uGUI-2017.1/Editor/UI/AssemblyInfo.cs.meta | 13 + Assets/uGUI-2017.1/Editor/UI/ButtonEditor.cs | 29 + Assets/uGUI-2017.1/Editor/UI/ButtonEditor.cs.meta | 13 + Assets/uGUI-2017.1/Editor/UI/CanvasScalerEditor.cs | 160 ++ .../Editor/UI/CanvasScalerEditor.cs.meta | 13 + .../Editor/UI/ContentSizeFitterEditor.cs | 29 + .../Editor/UI/ContentSizeFitterEditor.cs.meta | 13 + Assets/uGUI-2017.1/Editor/UI/DropdownEditor.cs | 48 + .../uGUI-2017.1/Editor/UI/DropdownEditor.cs.meta | 13 + Assets/uGUI-2017.1/Editor/UI/GraphicEditor.cs | 93 + Assets/uGUI-2017.1/Editor/UI/GraphicEditor.cs.meta | 13 + .../uGUI-2017.1/Editor/UI/GridLayoutGroupEditor.cs | 52 + .../Editor/UI/GridLayoutGroupEditor.cs.meta | 13 + .../UI/HorizontalOrVerticalLayoutGroupEditor.cs | 75 + .../HorizontalOrVerticalLayoutGroupEditor.cs.meta | 13 + Assets/uGUI-2017.1/Editor/UI/ImageEditor.cs | 251 ++ Assets/uGUI-2017.1/Editor/UI/ImageEditor.cs.meta | 13 + Assets/uGUI-2017.1/Editor/UI/InputFieldEditor.cs | 139 ++ .../uGUI-2017.1/Editor/UI/InputFieldEditor.cs.meta | 13 + .../Editor/UI/InterceptedEventsPreview.cs | 304 +++ .../Editor/UI/InterceptedEventsPreview.cs.meta | 13 + .../uGUI-2017.1/Editor/UI/LayoutElementEditor.cs | 102 + .../Editor/UI/LayoutElementEditor.cs.meta | 13 + .../Editor/UI/LayoutPropertiesPreview.cs | 123 + .../Editor/UI/LayoutPropertiesPreview.cs.meta | 13 + Assets/uGUI-2017.1/Editor/UI/MaskEditor.cs | 28 + Assets/uGUI-2017.1/Editor/UI/MaskEditor.cs.meta | 13 + Assets/uGUI-2017.1/Editor/UI/MenuOptions.cs | 282 +++ Assets/uGUI-2017.1/Editor/UI/MenuOptions.cs.meta | 13 + .../uGUI-2017.1/Editor/UI/PrefabLayoutRebuilder.cs | 24 + .../Editor/UI/PrefabLayoutRebuilder.cs.meta | 13 + Assets/uGUI-2017.1/Editor/UI/PropertyDrawers.meta | 10 + .../UI/PropertyDrawers/AnimationTriggersDrawer.cs | 33 + .../AnimationTriggersDrawer.cs.meta | 13 + .../Editor/UI/PropertyDrawers/ColorBlockDrawer.cs | 39 + .../UI/PropertyDrawers/ColorBlockDrawer.cs.meta | 13 + .../UI/PropertyDrawers/DropdownOptionListDrawer.cs | 59 + .../DropdownOptionListDrawer.cs.meta | 13 + .../Editor/UI/PropertyDrawers/FontDataDrawer.cs | 512 ++++ .../UI/PropertyDrawers/FontDataDrawer.cs.meta | 13 + .../Editor/UI/PropertyDrawers/NavigationDrawer.cs | 83 + .../UI/PropertyDrawers/NavigationDrawer.cs.meta | 13 + .../Editor/UI/PropertyDrawers/SpriteStateDrawer.cs | 30 + .../UI/PropertyDrawers/SpriteStateDrawer.cs.meta | 13 + Assets/uGUI-2017.1/Editor/UI/RawImageEditor.cs | 107 + .../uGUI-2017.1/Editor/UI/RawImageEditor.cs.meta | 13 + Assets/uGUI-2017.1/Editor/UI/RectMask2DEditor.cs | 13 + .../uGUI-2017.1/Editor/UI/RectMask2DEditor.cs.meta | 13 + Assets/uGUI-2017.1/Editor/UI/ScrollRectEditor.cs | 172 ++ .../uGUI-2017.1/Editor/UI/ScrollRectEditor.cs.meta | 13 + Assets/uGUI-2017.1/Editor/UI/ScrollbarEditor.cs | 102 + .../uGUI-2017.1/Editor/UI/ScrollbarEditor.cs.meta | 13 + Assets/uGUI-2017.1/Editor/UI/SelectableEditor.cs | 370 +++ .../uGUI-2017.1/Editor/UI/SelectableEditor.cs.meta | 13 + .../uGUI-2017.1/Editor/UI/SelfControllerEditor.cs | 35 + .../Editor/UI/SelfControllerEditor.cs.meta | 13 + Assets/uGUI-2017.1/Editor/UI/SliderEditor.cs | 88 + Assets/uGUI-2017.1/Editor/UI/SliderEditor.cs.meta | 13 + Assets/uGUI-2017.1/Editor/UI/SpriteDrawUtility.cs | 200 ++ .../Editor/UI/SpriteDrawUtility.cs.meta | 13 + Assets/uGUI-2017.1/Editor/UI/TextEditor.cs | 40 + Assets/uGUI-2017.1/Editor/UI/TextEditor.cs.meta | 13 + Assets/uGUI-2017.1/Editor/UI/ToggleEditor.cs | 46 + Assets/uGUI-2017.1/Editor/UI/ToggleEditor.cs.meta | 13 + Assets/uGUI-2017.1/UnityEngine.UI.meta | 10 + 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 + 261 files changed, 23219 insertions(+) create mode 100644 Assets/Scenes.meta create mode 100644 Assets/Scenes/demo.unity create mode 100644 Assets/Scenes/demo.unity.meta create mode 100644 Assets/Scripts.meta create mode 100644 Assets/Scripts/Test.cs create mode 100644 Assets/Scripts/Test.cs.meta create mode 100644 Assets/uGUI-2017.1.meta create mode 100644 Assets/uGUI-2017.1/Editor.meta create mode 100644 Assets/uGUI-2017.1/Editor/EventSystem.meta create mode 100644 Assets/uGUI-2017.1/Editor/EventSystem/EventSystemEditor.cs create mode 100644 Assets/uGUI-2017.1/Editor/EventSystem/EventSystemEditor.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/EventSystem/EventTriggerEditor.cs create mode 100644 Assets/uGUI-2017.1/Editor/EventSystem/EventTriggerEditor.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/AspectRatioFitterEditor.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/AspectRatioFitterEditor.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/AssemblyInfo.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/AssemblyInfo.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/ButtonEditor.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/ButtonEditor.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/CanvasScalerEditor.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/CanvasScalerEditor.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/ContentSizeFitterEditor.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/ContentSizeFitterEditor.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/DropdownEditor.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/DropdownEditor.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/GraphicEditor.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/GraphicEditor.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/GridLayoutGroupEditor.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/GridLayoutGroupEditor.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/HorizontalOrVerticalLayoutGroupEditor.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/HorizontalOrVerticalLayoutGroupEditor.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/ImageEditor.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/ImageEditor.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/InputFieldEditor.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/InputFieldEditor.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/InterceptedEventsPreview.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/InterceptedEventsPreview.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/LayoutElementEditor.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/LayoutElementEditor.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/LayoutPropertiesPreview.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/LayoutPropertiesPreview.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/MaskEditor.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/MaskEditor.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/MenuOptions.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/MenuOptions.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/PrefabLayoutRebuilder.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/PrefabLayoutRebuilder.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/PropertyDrawers.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/AnimationTriggersDrawer.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/AnimationTriggersDrawer.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/ColorBlockDrawer.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/ColorBlockDrawer.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/DropdownOptionListDrawer.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/DropdownOptionListDrawer.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/FontDataDrawer.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/FontDataDrawer.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/NavigationDrawer.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/NavigationDrawer.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/SpriteStateDrawer.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/SpriteStateDrawer.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/RawImageEditor.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/RawImageEditor.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/RectMask2DEditor.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/RectMask2DEditor.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/ScrollRectEditor.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/ScrollRectEditor.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/ScrollbarEditor.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/ScrollbarEditor.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/SelectableEditor.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/SelectableEditor.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/SelfControllerEditor.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/SelfControllerEditor.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/SliderEditor.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/SliderEditor.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/SpriteDrawUtility.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/SpriteDrawUtility.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/TextEditor.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/TextEditor.cs.meta create mode 100644 Assets/uGUI-2017.1/Editor/UI/ToggleEditor.cs create mode 100644 Assets/uGUI-2017.1/Editor/UI/ToggleEditor.cs.meta create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI.meta 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') diff --git a/Assets/Scenes.meta b/Assets/Scenes.meta new file mode 100644 index 0000000..960aa0f --- /dev/null +++ b/Assets/Scenes.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9073588b062150149a782867cc91771e +folderAsset: yes +timeCreated: 1602121121 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/demo.unity b/Assets/Scenes/demo.unity new file mode 100644 index 0000000..5b9ff0c --- /dev/null +++ b/Assets/Scenes/demo.unity @@ -0,0 +1,600 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 8 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0.4465782, g: 0.49641252, b: 0.5748167, a: 1} +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 0 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 9 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 0 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 500 + m_PVRBounces: 2 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVRFilteringMode: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &533663744 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 533663745} + - component: {fileID: 533663748} + - component: {fileID: 533663747} + - component: {fileID: 533663746} + m_Layer: 5 + m_Name: Button + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &533663745 +RectTransform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 533663744} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 640337471} + m_Father: {fileID: 800438999} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 160, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &533663746 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 533663744} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b55754d97ca63cd4dbfeea25c980c065, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 0} + m_OnClick: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, Assembly-CSharp, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null +--- !u!114 &533663747 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 533663744} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: bd103b5bbc9cef740b4136f9f7a7b109, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, Assembly-CSharp, + Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 +--- !u!222 &533663748 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 533663744} +--- !u!1 &640337470 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 640337471} + - component: {fileID: 640337473} + - component: {fileID: 640337472} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &640337471 +RectTransform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 640337470} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 533663745} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &640337472 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 640337470} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 09f4224b0cded254a977e1ac3c9e2470, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, Assembly-CSharp, + Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Button +--- !u!222 &640337473 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 640337470} +--- !u!1 &800438995 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 800438999} + - component: {fileID: 800438998} + - component: {fileID: 800438997} + - component: {fileID: 800438996} + m_Layer: 5 + m_Name: Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &800438996 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 800438995} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 67bf38e07c362674ebc60bfbd6dafa3a, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!114 &800438997 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 800438995} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: debcf26b89013e446a6de5574715c5af, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 0 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 800, y: 600} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 +--- !u!223 &800438998 +Canvas: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 800438995} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 0 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_AdditionalShaderChannelsFlag: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!224 &800438999 +RectTransform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 800438995} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 494.5, y: 307, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 533663745} + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 100, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!1 &1360287297 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1360287301} + - component: {fileID: 1360287300} + - component: {fileID: 1360287299} + - component: {fileID: 1360287298} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &1360287298 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1360287297} + m_Enabled: 1 +--- !u!124 &1360287299 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1360287297} + m_Enabled: 1 +--- !u!20 &1360287300 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1360287297} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &1360287301 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1360287297} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1400184286 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1400184288} + - component: {fileID: 1400184287} + m_Layer: 0 + m_Name: Directional Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!108 &1400184287 +Light: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1400184286} + m_Enabled: 1 + serializedVersion: 8 + m_Type: 1 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_CookieSize: 10 + m_Shadows: + m_Type: 2 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_Lightmapping: 4 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &1400184288 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1400184286} + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &1827934287 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1827934290} + - component: {fileID: 1827934289} + - component: {fileID: 1827934288} + m_Layer: 0 + m_Name: EventSystem + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1827934288 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1827934287} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e2665fa6a1fb2474d8a5c19f72f8d0c6, type: 3} + m_Name: + m_EditorClassIdentifier: + m_HorizontalAxis: Horizontal + m_VerticalAxis: Vertical + m_SubmitButton: Submit + m_CancelButton: Cancel + m_InputActionsPerSecond: 10 + m_RepeatDelay: 0.5 + m_ForceModuleActive: 0 +--- !u!114 &1827934289 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1827934287} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 47dabc676519a2840ab00d4e00228528, type: 3} + m_Name: + m_EditorClassIdentifier: + m_FirstSelected: {fileID: 0} + m_sendNavigationEvents: 1 + m_DragThreshold: 5 +--- !u!4 &1827934290 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1827934287} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Scenes/demo.unity.meta b/Assets/Scenes/demo.unity.meta new file mode 100644 index 0000000..5d6fb8e --- /dev/null +++ b/Assets/Scenes/demo.unity.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 660039c742573e142a9b548ff909fd26 +timeCreated: 1602121122 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts.meta b/Assets/Scripts.meta new file mode 100644 index 0000000..7634d0e --- /dev/null +++ b/Assets/Scripts.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d74d436a8b9b5964f8c81655dd3aef38 +folderAsset: yes +timeCreated: 1602121433 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Test.cs b/Assets/Scripts/Test.cs new file mode 100644 index 0000000..11b9f8c --- /dev/null +++ b/Assets/Scripts/Test.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Test : MonoBehaviour { + + // Use this for initialization + void Start () { + + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/Assets/Scripts/Test.cs.meta b/Assets/Scripts/Test.cs.meta new file mode 100644 index 0000000..472b16d --- /dev/null +++ b/Assets/Scripts/Test.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 888d6900b9dcda148bf20be9c4b300c9 +timeCreated: 1602121488 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 10300, guid: 0000000000000000f000000000000000, type: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1.meta b/Assets/uGUI-2017.1.meta new file mode 100644 index 0000000..d438e49 --- /dev/null +++ b/Assets/uGUI-2017.1.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 72a3e4ebf6f9bfc48bc008cde9512ce4 +folderAsset: yes +timeCreated: 1602119280 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor.meta b/Assets/uGUI-2017.1/Editor.meta new file mode 100644 index 0000000..9bf6899 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: f2ad34301c84c4e44b5376c99a3b956f +folderAsset: yes +timeCreated: 1602119560 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/EventSystem.meta b/Assets/uGUI-2017.1/Editor/EventSystem.meta new file mode 100644 index 0000000..5ffb514 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/EventSystem.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 01fe218d8ac061941a01b34673d19eaa +folderAsset: yes +timeCreated: 1602119280 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/EventSystem/EventSystemEditor.cs b/Assets/uGUI-2017.1/Editor/EventSystem/EventSystemEditor.cs new file mode 100644 index 0000000..729b584 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/EventSystem/EventSystemEditor.cs @@ -0,0 +1,66 @@ +using UnityEngine; +using UnityEngine.EventSystems; + +namespace UnityEditor.EventSystems +{ + [CustomEditor(typeof(EventSystem), true)] + public class EventSystemEditor : Editor + { + public override void OnInspectorGUI() + { + DrawDefaultInspector(); + + var eventSystem = target as EventSystem; + if (eventSystem == null) + return; + + if (eventSystem.GetComponent() != null) + return; + + // no input modules :( + if (GUILayout.Button("Add Default Input Modules")) + { + Undo.AddComponent(eventSystem.gameObject); + } + } + + public override bool HasPreviewGUI() + { + return Application.isPlaying; + } + + private GUIStyle m_PreviewLabelStyle; + + protected GUIStyle previewLabelStyle + { + get + { + if (m_PreviewLabelStyle == null) + { + m_PreviewLabelStyle = new GUIStyle("PreOverlayLabel") + { + richText = true, + alignment = TextAnchor.UpperLeft, + fontStyle = FontStyle.Normal + }; + } + + return m_PreviewLabelStyle; + } + } + + public override bool RequiresConstantRepaint() + { + return Application.isPlaying; + } + + public override void OnPreviewGUI(Rect rect, GUIStyle background) + { + var system = target as EventSystem; + if (system == null) + return; + + GUI.Label(rect, system.ToString(), previewLabelStyle); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/EventSystem/EventSystemEditor.cs.meta b/Assets/uGUI-2017.1/Editor/EventSystem/EventSystemEditor.cs.meta new file mode 100644 index 0000000..adf1b92 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/EventSystem/EventSystemEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 3b529ab7403fbf24cb6439ab7da2ce2b +timeCreated: 1602119378 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/EventSystem/EventTriggerEditor.cs b/Assets/uGUI-2017.1/Editor/EventSystem/EventTriggerEditor.cs new file mode 100644 index 0000000..37811df --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/EventSystem/EventTriggerEditor.cs @@ -0,0 +1,122 @@ +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace UnityEditor.EventSystems +{ + [CustomEditor(typeof(EventTrigger), true)] + public class EventTriggerEditor : Editor + { + SerializedProperty m_DelegatesProperty; + + GUIContent m_IconToolbarMinus; + GUIContent m_EventIDName; + GUIContent[] m_EventTypes; + GUIContent m_AddButonContent; + + protected virtual void OnEnable() + { + m_DelegatesProperty = serializedObject.FindProperty("m_Delegates"); + m_AddButonContent = new GUIContent("Add New Event Type"); + m_EventIDName = new GUIContent(""); + // Have to create a copy since otherwise the tooltip will be overwritten. + m_IconToolbarMinus = new GUIContent(EditorGUIUtility.IconContent("Toolbar Minus")); + m_IconToolbarMinus.tooltip = "Remove all events in this list."; + + string[] eventNames = Enum.GetNames(typeof(EventTriggerType)); + m_EventTypes = new GUIContent[eventNames.Length]; + for (int i = 0; i < eventNames.Length; ++i) + { + m_EventTypes[i] = new GUIContent(eventNames[i]); + } + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + int toBeRemovedEntry = -1; + + EditorGUILayout.Space(); + + Vector2 removeButtonSize = GUIStyle.none.CalcSize(m_IconToolbarMinus); + + for (int i = 0; i < m_DelegatesProperty.arraySize; ++i) + { + SerializedProperty delegateProperty = m_DelegatesProperty.GetArrayElementAtIndex(i); + SerializedProperty eventProperty = delegateProperty.FindPropertyRelative("eventID"); + SerializedProperty callbacksProperty = delegateProperty.FindPropertyRelative("callback"); + m_EventIDName.text = eventProperty.enumDisplayNames[eventProperty.enumValueIndex]; + + EditorGUILayout.PropertyField(callbacksProperty, m_EventIDName); + Rect callbackRect = GUILayoutUtility.GetLastRect(); + + Rect removeButtonPos = new Rect(callbackRect.xMax - removeButtonSize.x - 8, callbackRect.y + 1, removeButtonSize.x, removeButtonSize.y); + if (GUI.Button(removeButtonPos, m_IconToolbarMinus, GUIStyle.none)) + { + toBeRemovedEntry = i; + } + + EditorGUILayout.Space(); + } + + if (toBeRemovedEntry > -1) + { + RemoveEntry(toBeRemovedEntry); + } + + Rect btPosition = GUILayoutUtility.GetRect(m_AddButonContent, GUI.skin.button); + const float addButonWidth = 200f; + btPosition.x = btPosition.x + (btPosition.width - addButonWidth) / 2; + btPosition.width = addButonWidth; + if (GUI.Button(btPosition, m_AddButonContent)) + { + ShowAddTriggermenu(); + } + + serializedObject.ApplyModifiedProperties(); + } + + private void RemoveEntry(int toBeRemovedEntry) + { + m_DelegatesProperty.DeleteArrayElementAtIndex(toBeRemovedEntry); + } + + void ShowAddTriggermenu() + { + // Now create the menu, add items and show it + GenericMenu menu = new GenericMenu(); + for (int i = 0; i < m_EventTypes.Length; ++i) + { + bool active = true; + + // Check if we already have a Entry for the current eventType, if so, disable it + for (int p = 0; p < m_DelegatesProperty.arraySize; ++p) + { + SerializedProperty delegateEntry = m_DelegatesProperty.GetArrayElementAtIndex(p); + SerializedProperty eventProperty = delegateEntry.FindPropertyRelative("eventID"); + if (eventProperty.enumValueIndex == i) + { + active = false; + } + } + if (active) + menu.AddItem(m_EventTypes[i], false, OnAddNewSelected, i); + else + menu.AddDisabledItem(m_EventTypes[i]); + } + menu.ShowAsContext(); + Event.current.Use(); + } + + private void OnAddNewSelected(object index) + { + int selected = (int)index; + + m_DelegatesProperty.arraySize += 1; + SerializedProperty delegateEntry = m_DelegatesProperty.GetArrayElementAtIndex(m_DelegatesProperty.arraySize - 1); + SerializedProperty eventProperty = delegateEntry.FindPropertyRelative("eventID"); + eventProperty.enumValueIndex = selected; + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/EventSystem/EventTriggerEditor.cs.meta b/Assets/uGUI-2017.1/Editor/EventSystem/EventTriggerEditor.cs.meta new file mode 100644 index 0000000..7271bfc --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/EventSystem/EventTriggerEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 1316b73e356230a498f95e64a50672d6 +timeCreated: 1602119377 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI.meta b/Assets/uGUI-2017.1/Editor/UI.meta new file mode 100644 index 0000000..82bc206 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 427ac1252da1fe044956726ab7c0e899 +folderAsset: yes +timeCreated: 1602119280 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/AspectRatioFitterEditor.cs b/Assets/uGUI-2017.1/Editor/UI/AspectRatioFitterEditor.cs new file mode 100644 index 0000000..2901460 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/AspectRatioFitterEditor.cs @@ -0,0 +1,29 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(AspectRatioFitter), true)] + [CanEditMultipleObjects] + public class AspectRatioFitterEditor : SelfControllerEditor + { + SerializedProperty m_AspectMode; + SerializedProperty m_AspectRatio; + + protected virtual void OnEnable() + { + m_AspectMode = serializedObject.FindProperty("m_AspectMode"); + m_AspectRatio = serializedObject.FindProperty("m_AspectRatio"); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + EditorGUILayout.PropertyField(m_AspectMode); + EditorGUILayout.PropertyField(m_AspectRatio); + serializedObject.ApplyModifiedProperties(); + + base.OnInspectorGUI(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/AspectRatioFitterEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/AspectRatioFitterEditor.cs.meta new file mode 100644 index 0000000..0e02140 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/AspectRatioFitterEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 47edf64b98c2574419b1a0c2b1cb4a78 +timeCreated: 1602119378 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/AssemblyInfo.cs b/Assets/uGUI-2017.1/Editor/UI/AssemblyInfo.cs new file mode 100644 index 0000000..9aa72dc --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/AssemblyInfo.cs @@ -0,0 +1,38 @@ +using System.Reflection; +using System.Runtime.InteropServices; +using UnityEngine; + + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("UnityEditor.UI")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Unity Technologies")] +[assembly: AssemblyProduct("guisystemeditor")] +[assembly: AssemblyCopyright("Copyright © Unity Technologies 2013")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: AssemblyIsEditorAssembly] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ad7418c3-5d25-4670-b468-8e7196596d42")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Assets/uGUI-2017.1/Editor/UI/AssemblyInfo.cs.meta b/Assets/uGUI-2017.1/Editor/UI/AssemblyInfo.cs.meta new file mode 100644 index 0000000..9d5566f --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/AssemblyInfo.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 17fd9454424a6004e9982ef22617b070 +timeCreated: 1602119377 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/ButtonEditor.cs b/Assets/uGUI-2017.1/Editor/UI/ButtonEditor.cs new file mode 100644 index 0000000..9676934 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/ButtonEditor.cs @@ -0,0 +1,29 @@ +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(Button), true)] + [CanEditMultipleObjects] + public class ButtonEditor : SelectableEditor + { + SerializedProperty m_OnClickProperty; + + protected override void OnEnable() + { + base.OnEnable(); + m_OnClickProperty = serializedObject.FindProperty("m_OnClick"); + } + + public override void OnInspectorGUI() + { + base.OnInspectorGUI(); + EditorGUILayout.Space(); + + serializedObject.Update(); + + EditorGUILayout.PropertyField(m_OnClickProperty); + + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/ButtonEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/ButtonEditor.cs.meta new file mode 100644 index 0000000..3d63fb0 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/ButtonEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 87698847489a1eb49a05be64fb084cc3 +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/CanvasScalerEditor.cs b/Assets/uGUI-2017.1/Editor/UI/CanvasScalerEditor.cs new file mode 100644 index 0000000..883d300 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/CanvasScalerEditor.cs @@ -0,0 +1,160 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(CanvasScaler), true)] + [CanEditMultipleObjects] + public class CanvasScalerEditor : Editor + { + SerializedProperty m_UiScaleMode; + SerializedProperty m_ScaleFactor; + SerializedProperty m_ReferenceResolution; + SerializedProperty m_ScreenMatchMode; + SerializedProperty m_MatchWidthOrHeight; + SerializedProperty m_PhysicalUnit; + SerializedProperty m_FallbackScreenDPI; + SerializedProperty m_DefaultSpriteDPI; + SerializedProperty m_DynamicPixelsPerUnit; + SerializedProperty m_ReferencePixelsPerUnit; + + const int kSliderEndpointLabelsHeight = 12; + + private class Styles + { + public GUIContent matchContent; + public GUIContent widthContent; + public GUIContent heightContent; + public GUIContent uiScaleModeContent; + public GUIStyle leftAlignedLabel; + public GUIStyle rightAlignedLabel; + + public Styles() + { + matchContent = new GUIContent("Match"); + widthContent = new GUIContent("Width"); + heightContent = new GUIContent("Height"); + uiScaleModeContent = new GUIContent("UI Scale Mode"); + + leftAlignedLabel = new GUIStyle(EditorStyles.label); + rightAlignedLabel = new GUIStyle(EditorStyles.label); + rightAlignedLabel.alignment = TextAnchor.MiddleRight; + } + } + private static Styles s_Styles; + + protected virtual void OnEnable() + { + m_UiScaleMode = serializedObject.FindProperty("m_UiScaleMode"); + m_ScaleFactor = serializedObject.FindProperty("m_ScaleFactor"); + m_ReferenceResolution = serializedObject.FindProperty("m_ReferenceResolution"); + m_ScreenMatchMode = serializedObject.FindProperty("m_ScreenMatchMode"); + m_MatchWidthOrHeight = serializedObject.FindProperty("m_MatchWidthOrHeight"); + m_PhysicalUnit = serializedObject.FindProperty("m_PhysicalUnit"); + m_FallbackScreenDPI = serializedObject.FindProperty("m_FallbackScreenDPI"); + m_DefaultSpriteDPI = serializedObject.FindProperty("m_DefaultSpriteDPI"); + m_DynamicPixelsPerUnit = serializedObject.FindProperty("m_DynamicPixelsPerUnit"); + m_ReferencePixelsPerUnit = serializedObject.FindProperty("m_ReferencePixelsPerUnit"); + } + + public override void OnInspectorGUI() + { + if (s_Styles == null) + s_Styles = new Styles(); + + bool allAreRoot = true; + bool showWorldDiffers = false; + bool showWorld = ((target as CanvasScaler).GetComponent().renderMode == RenderMode.WorldSpace); + for (int i = 0; i < targets.Length; i++) + { + CanvasScaler scaler = targets[i] as CanvasScaler; + Canvas canvas = scaler.GetComponent(); + if (!canvas.isRootCanvas) + { + allAreRoot = false; + break; + } + if (showWorld && canvas.renderMode != RenderMode.WorldSpace || !showWorld && canvas.renderMode == RenderMode.WorldSpace) + { + showWorldDiffers = true; + break; + } + } + + if (!allAreRoot) + { + EditorGUILayout.HelpBox("Non-root Canvases will not be scaled.", MessageType.Warning); + return; + } + + serializedObject.Update(); + + EditorGUI.showMixedValue = showWorldDiffers; + using (new EditorGUI.DisabledScope(showWorld || showWorldDiffers)) + { + if (showWorld || showWorldDiffers) + { + EditorGUILayout.Popup(s_Styles.uiScaleModeContent.text, 0, new[] { "World" }); + } + else + { + EditorGUILayout.PropertyField(m_UiScaleMode, s_Styles.uiScaleModeContent); + } + } + EditorGUI.showMixedValue = false; + + if (!showWorldDiffers && !(!showWorld && m_UiScaleMode.hasMultipleDifferentValues)) + { + EditorGUILayout.Space(); + + // World Canvas + if (showWorld) + { + EditorGUILayout.PropertyField(m_DynamicPixelsPerUnit); + } + // Constant pixel size + else if (m_UiScaleMode.enumValueIndex == (int)CanvasScaler.ScaleMode.ConstantPixelSize) + { + EditorGUILayout.PropertyField(m_ScaleFactor); + } + // Scale with screen size + else if (m_UiScaleMode.enumValueIndex == (int)CanvasScaler.ScaleMode.ScaleWithScreenSize) + { + EditorGUILayout.PropertyField(m_ReferenceResolution); + EditorGUILayout.PropertyField(m_ScreenMatchMode); + if (m_ScreenMatchMode.enumValueIndex == (int)CanvasScaler.ScreenMatchMode.MatchWidthOrHeight && !m_ScreenMatchMode.hasMultipleDifferentValues) + { + Rect r = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight + kSliderEndpointLabelsHeight); + DualLabeledSlider(r, m_MatchWidthOrHeight, s_Styles.matchContent, s_Styles.widthContent, s_Styles.heightContent); + } + } + // Constant physical size + else if (m_UiScaleMode.enumValueIndex == (int)CanvasScaler.ScaleMode.ConstantPhysicalSize) + { + EditorGUILayout.PropertyField(m_PhysicalUnit); + EditorGUILayout.PropertyField(m_FallbackScreenDPI); + EditorGUILayout.PropertyField(m_DefaultSpriteDPI); + } + + EditorGUILayout.PropertyField(m_ReferencePixelsPerUnit); + } + + serializedObject.ApplyModifiedProperties(); + } + + private static void DualLabeledSlider(Rect position, SerializedProperty property, GUIContent mainLabel, GUIContent labelLeft, GUIContent labelRight) + { + position.height = EditorGUIUtility.singleLineHeight; + Rect pos = position; + + position.y += 12; + position.xMin += EditorGUIUtility.labelWidth; + position.xMax -= EditorGUIUtility.fieldWidth; + + GUI.Label(position, labelLeft, s_Styles.leftAlignedLabel); + GUI.Label(position, labelRight, s_Styles.rightAlignedLabel); + + EditorGUI.PropertyField(pos, property, mainLabel); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/CanvasScalerEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/CanvasScalerEditor.cs.meta new file mode 100644 index 0000000..e92d213 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/CanvasScalerEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 03c5d085f2f1a3d468f8073e18105b77 +timeCreated: 1602119377 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/ContentSizeFitterEditor.cs b/Assets/uGUI-2017.1/Editor/UI/ContentSizeFitterEditor.cs new file mode 100644 index 0000000..87fdbef --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/ContentSizeFitterEditor.cs @@ -0,0 +1,29 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(ContentSizeFitter), true)] + [CanEditMultipleObjects] + public class ContentSizeFitterEditor : SelfControllerEditor + { + SerializedProperty m_HorizontalFit; + SerializedProperty m_VerticalFit; + + protected virtual void OnEnable() + { + m_HorizontalFit = serializedObject.FindProperty("m_HorizontalFit"); + m_VerticalFit = serializedObject.FindProperty("m_VerticalFit"); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + EditorGUILayout.PropertyField(m_HorizontalFit, true); + EditorGUILayout.PropertyField(m_VerticalFit, true); + serializedObject.ApplyModifiedProperties(); + + base.OnInspectorGUI(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/ContentSizeFitterEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/ContentSizeFitterEditor.cs.meta new file mode 100644 index 0000000..9f09d06 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/ContentSizeFitterEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 906585751f53cee439d265a08589edcf +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/DropdownEditor.cs b/Assets/uGUI-2017.1/Editor/UI/DropdownEditor.cs new file mode 100644 index 0000000..1dd16e4 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/DropdownEditor.cs @@ -0,0 +1,48 @@ +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(Dropdown), true)] + [CanEditMultipleObjects] + public class DropdownEditor : SelectableEditor + { + SerializedProperty m_Template; + SerializedProperty m_CaptionText; + SerializedProperty m_CaptionImage; + SerializedProperty m_ItemText; + SerializedProperty m_ItemImage; + SerializedProperty m_OnSelectionChanged; + SerializedProperty m_Value; + SerializedProperty m_Options; + + protected override void OnEnable() + { + base.OnEnable(); + m_Template = serializedObject.FindProperty("m_Template"); + m_CaptionText = serializedObject.FindProperty("m_CaptionText"); + m_CaptionImage = serializedObject.FindProperty("m_CaptionImage"); + m_ItemText = serializedObject.FindProperty("m_ItemText"); + m_ItemImage = serializedObject.FindProperty("m_ItemImage"); + m_OnSelectionChanged = serializedObject.FindProperty("m_OnValueChanged"); + m_Value = serializedObject.FindProperty("m_Value"); + m_Options = serializedObject.FindProperty("m_Options"); + } + + public override void OnInspectorGUI() + { + base.OnInspectorGUI(); + EditorGUILayout.Space(); + + serializedObject.Update(); + EditorGUILayout.PropertyField(m_Template); + EditorGUILayout.PropertyField(m_CaptionText); + EditorGUILayout.PropertyField(m_CaptionImage); + EditorGUILayout.PropertyField(m_ItemText); + EditorGUILayout.PropertyField(m_ItemImage); + EditorGUILayout.PropertyField(m_Value); + EditorGUILayout.PropertyField(m_Options); + EditorGUILayout.PropertyField(m_OnSelectionChanged); + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/DropdownEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/DropdownEditor.cs.meta new file mode 100644 index 0000000..1f51b0a --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/DropdownEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7b05a7b6f5fe0744a850680d5f282a6a +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/GraphicEditor.cs b/Assets/uGUI-2017.1/Editor/UI/GraphicEditor.cs new file mode 100644 index 0000000..3fc16ee --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/GraphicEditor.cs @@ -0,0 +1,93 @@ +using System.Linq; +using UnityEditor.AnimatedValues; +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + /// + /// Editor class used to edit UI Graphics. + /// + + [CustomEditor(typeof(MaskableGraphic), false)] + [CanEditMultipleObjects] + public class GraphicEditor : Editor + { + protected SerializedProperty m_Script; + protected SerializedProperty m_Color; + protected SerializedProperty m_Material; + protected SerializedProperty m_RaycastTarget; + + private GUIContent m_CorrectButtonContent; + protected AnimBool m_ShowNativeSize; + + protected virtual void OnDisable() + { + Tools.hidden = false; + m_ShowNativeSize.valueChanged.RemoveListener(Repaint); + } + + protected virtual void OnEnable() + { + m_CorrectButtonContent = new GUIContent("Set Native Size", "Sets the size to match the content."); + + m_Script = serializedObject.FindProperty("m_Script"); + m_Color = serializedObject.FindProperty("m_Color"); + m_Material = serializedObject.FindProperty("m_Material"); + m_RaycastTarget = serializedObject.FindProperty("m_RaycastTarget"); + + m_ShowNativeSize = new AnimBool(false); + m_ShowNativeSize.valueChanged.AddListener(Repaint); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + EditorGUILayout.PropertyField(m_Script); + AppearanceControlsGUI(); + RaycastControlsGUI(); + serializedObject.ApplyModifiedProperties(); + } + + protected void SetShowNativeSize(bool show, bool instant) + { + if (instant) + m_ShowNativeSize.value = show; + else + m_ShowNativeSize.target = show; + } + + protected void NativeSizeButtonGUI() + { + if (EditorGUILayout.BeginFadeGroup(m_ShowNativeSize.faded)) + { + EditorGUILayout.BeginHorizontal(); + { + GUILayout.Space(EditorGUIUtility.labelWidth); + if (GUILayout.Button(m_CorrectButtonContent, EditorStyles.miniButton)) + { + foreach (Graphic graphic in targets.Select(obj => obj as Graphic)) + { + Undo.RecordObject(graphic.rectTransform, "Set Native Size"); + graphic.SetNativeSize(); + EditorUtility.SetDirty(graphic); + } + } + } + EditorGUILayout.EndHorizontal(); + } + EditorGUILayout.EndFadeGroup(); + } + + protected void AppearanceControlsGUI() + { + EditorGUILayout.PropertyField(m_Color); + EditorGUILayout.PropertyField(m_Material); + } + + protected void RaycastControlsGUI() + { + EditorGUILayout.PropertyField(m_RaycastTarget); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/GraphicEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/GraphicEditor.cs.meta new file mode 100644 index 0000000..d6a4459 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/GraphicEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 46f6948c5f4af7747b8bd84eaff48829 +timeCreated: 1602119378 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/GridLayoutGroupEditor.cs b/Assets/uGUI-2017.1/Editor/UI/GridLayoutGroupEditor.cs new file mode 100644 index 0000000..462e99a --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/GridLayoutGroupEditor.cs @@ -0,0 +1,52 @@ +using UnityEngine; +using UnityEngine.UI; +using UnityEditorInternal; +using UnityEditor.AnimatedValues; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(GridLayoutGroup), true)] + [CanEditMultipleObjects] + public class GridLayoutGroupEditor : Editor + { + SerializedProperty m_Padding; + SerializedProperty m_CellSize; + SerializedProperty m_Spacing; + SerializedProperty m_StartCorner; + SerializedProperty m_StartAxis; + SerializedProperty m_ChildAlignment; + SerializedProperty m_Constraint; + SerializedProperty m_ConstraintCount; + + protected virtual void OnEnable() + { + m_Padding = serializedObject.FindProperty("m_Padding"); + m_CellSize = serializedObject.FindProperty("m_CellSize"); + m_Spacing = serializedObject.FindProperty("m_Spacing"); + m_StartCorner = serializedObject.FindProperty("m_StartCorner"); + m_StartAxis = serializedObject.FindProperty("m_StartAxis"); + m_ChildAlignment = serializedObject.FindProperty("m_ChildAlignment"); + m_Constraint = serializedObject.FindProperty("m_Constraint"); + m_ConstraintCount = serializedObject.FindProperty("m_ConstraintCount"); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + EditorGUILayout.PropertyField(m_Padding, true); + EditorGUILayout.PropertyField(m_CellSize, true); + EditorGUILayout.PropertyField(m_Spacing, true); + EditorGUILayout.PropertyField(m_StartCorner, true); + EditorGUILayout.PropertyField(m_StartAxis, true); + EditorGUILayout.PropertyField(m_ChildAlignment, true); + EditorGUILayout.PropertyField(m_Constraint, true); + if (m_Constraint.enumValueIndex > 0) + { + EditorGUI.indentLevel++; + EditorGUILayout.PropertyField(m_ConstraintCount, true); + EditorGUI.indentLevel--; + } + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/GridLayoutGroupEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/GridLayoutGroupEditor.cs.meta new file mode 100644 index 0000000..b0931bf --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/GridLayoutGroupEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 41b243187f9b6264e8f982c805ac671d +timeCreated: 1602119378 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/HorizontalOrVerticalLayoutGroupEditor.cs b/Assets/uGUI-2017.1/Editor/UI/HorizontalOrVerticalLayoutGroupEditor.cs new file mode 100644 index 0000000..01b17b8 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/HorizontalOrVerticalLayoutGroupEditor.cs @@ -0,0 +1,75 @@ +using UnityEngine; +using UnityEngine.UI; +using UnityEditorInternal; +using UnityEditor.AnimatedValues; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(HorizontalOrVerticalLayoutGroup), true)] + [CanEditMultipleObjects] + public class HorizontalOrVerticalLayoutGroupEditor : Editor + { + SerializedProperty m_Padding; + SerializedProperty m_Spacing; + SerializedProperty m_ChildAlignment; + SerializedProperty m_ChildControlWidth; + SerializedProperty m_ChildControlHeight; + SerializedProperty m_ChildForceExpandWidth; + SerializedProperty m_ChildForceExpandHeight; + + protected virtual void OnEnable() + { + m_Padding = serializedObject.FindProperty("m_Padding"); + m_Spacing = serializedObject.FindProperty("m_Spacing"); + m_ChildAlignment = serializedObject.FindProperty("m_ChildAlignment"); + m_ChildControlWidth = serializedObject.FindProperty("m_ChildControlWidth"); + m_ChildControlHeight = serializedObject.FindProperty("m_ChildControlHeight"); + m_ChildForceExpandWidth = serializedObject.FindProperty("m_ChildForceExpandWidth"); + m_ChildForceExpandHeight = serializedObject.FindProperty("m_ChildForceExpandHeight"); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + EditorGUILayout.PropertyField(m_Padding, true); + EditorGUILayout.PropertyField(m_Spacing, true); + EditorGUILayout.PropertyField(m_ChildAlignment, true); + + Rect rect = EditorGUILayout.GetControlRect(); + rect = EditorGUI.PrefixLabel(rect, -1, new GUIContent("Child Controls Size")); + rect.width = Mathf.Max(50, (rect.width - 4) / 3); + EditorGUIUtility.labelWidth = 50; + ToggleLeft(rect, m_ChildControlWidth, new GUIContent("Width")); + rect.x += rect.width + 2; + ToggleLeft(rect, m_ChildControlHeight, new GUIContent("Height")); + EditorGUIUtility.labelWidth = 0; + + rect = EditorGUILayout.GetControlRect(); + rect = EditorGUI.PrefixLabel(rect, -1, new GUIContent("Child Force Expand")); + rect.width = Mathf.Max(50, (rect.width - 4) / 3); + EditorGUIUtility.labelWidth = 50; + ToggleLeft(rect, m_ChildForceExpandWidth, new GUIContent("Width")); + rect.x += rect.width + 2; + ToggleLeft(rect, m_ChildForceExpandHeight, new GUIContent("Height")); + EditorGUIUtility.labelWidth = 0; + + serializedObject.ApplyModifiedProperties(); + } + + void ToggleLeft(Rect position, SerializedProperty property, GUIContent label) + { + bool toggle = property.boolValue; + EditorGUI.showMixedValue = property.hasMultipleDifferentValues; + EditorGUI.BeginChangeCheck(); + int oldIndent = EditorGUI.indentLevel; + EditorGUI.indentLevel = 0; + toggle = EditorGUI.ToggleLeft(position, label, toggle); + EditorGUI.indentLevel = oldIndent; + if (EditorGUI.EndChangeCheck()) + { + property.boolValue = property.hasMultipleDifferentValues ? true : !property.boolValue; + } + EditorGUI.showMixedValue = false; + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/HorizontalOrVerticalLayoutGroupEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/HorizontalOrVerticalLayoutGroupEditor.cs.meta new file mode 100644 index 0000000..f91a76b --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/HorizontalOrVerticalLayoutGroupEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: be8e8f57c18c7b64a8db44d2f8b15598 +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/ImageEditor.cs b/Assets/uGUI-2017.1/Editor/UI/ImageEditor.cs new file mode 100644 index 0000000..85da33f --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/ImageEditor.cs @@ -0,0 +1,251 @@ +using System.Linq; +using UnityEngine; +using UnityEditor.AnimatedValues; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + /// + /// Editor class used to edit UI Sprites. + /// + + [CustomEditor(typeof(Image), true)] + [CanEditMultipleObjects] + public class ImageEditor : GraphicEditor + { + SerializedProperty m_FillMethod; + SerializedProperty m_FillOrigin; + SerializedProperty m_FillAmount; + SerializedProperty m_FillClockwise; + SerializedProperty m_Type; + SerializedProperty m_FillCenter; + SerializedProperty m_Sprite; + SerializedProperty m_PreserveAspect; + GUIContent m_SpriteContent; + GUIContent m_SpriteTypeContent; + GUIContent m_ClockwiseContent; + AnimBool m_ShowSlicedOrTiled; + AnimBool m_ShowSliced; + AnimBool m_ShowTiled; + AnimBool m_ShowFilled; + AnimBool m_ShowType; + + protected override void OnEnable() + { + base.OnEnable(); + + m_SpriteContent = new GUIContent("Source Image"); + m_SpriteTypeContent = new GUIContent("Image Type"); + m_ClockwiseContent = new GUIContent("Clockwise"); + + m_Sprite = serializedObject.FindProperty("m_Sprite"); + m_Type = serializedObject.FindProperty("m_Type"); + m_FillCenter = serializedObject.FindProperty("m_FillCenter"); + m_FillMethod = serializedObject.FindProperty("m_FillMethod"); + m_FillOrigin = serializedObject.FindProperty("m_FillOrigin"); + m_FillClockwise = serializedObject.FindProperty("m_FillClockwise"); + m_FillAmount = serializedObject.FindProperty("m_FillAmount"); + m_PreserveAspect = serializedObject.FindProperty("m_PreserveAspect"); + + m_ShowType = new AnimBool(m_Sprite.objectReferenceValue != null); + m_ShowType.valueChanged.AddListener(Repaint); + + var typeEnum = (Image.Type)m_Type.enumValueIndex; + + m_ShowSlicedOrTiled = new AnimBool(!m_Type.hasMultipleDifferentValues && typeEnum == Image.Type.Sliced); + m_ShowSliced = new AnimBool(!m_Type.hasMultipleDifferentValues && typeEnum == Image.Type.Sliced); + m_ShowTiled = new AnimBool(!m_Type.hasMultipleDifferentValues && typeEnum == Image.Type.Tiled); + m_ShowFilled = new AnimBool(!m_Type.hasMultipleDifferentValues && typeEnum == Image.Type.Filled); + m_ShowSlicedOrTiled.valueChanged.AddListener(Repaint); + m_ShowSliced.valueChanged.AddListener(Repaint); + m_ShowTiled.valueChanged.AddListener(Repaint); + m_ShowFilled.valueChanged.AddListener(Repaint); + + SetShowNativeSize(true); + } + + protected override void OnDisable() + { + m_ShowType.valueChanged.RemoveListener(Repaint); + m_ShowSlicedOrTiled.valueChanged.RemoveListener(Repaint); + m_ShowSliced.valueChanged.RemoveListener(Repaint); + m_ShowTiled.valueChanged.RemoveListener(Repaint); + m_ShowFilled.valueChanged.RemoveListener(Repaint); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + SpriteGUI(); + AppearanceControlsGUI(); + RaycastControlsGUI(); + + m_ShowType.target = m_Sprite.objectReferenceValue != null; + if (EditorGUILayout.BeginFadeGroup(m_ShowType.faded)) + TypeGUI(); + EditorGUILayout.EndFadeGroup(); + + SetShowNativeSize(false); + if (EditorGUILayout.BeginFadeGroup(m_ShowNativeSize.faded)) + { + EditorGUI.indentLevel++; + EditorGUILayout.PropertyField(m_PreserveAspect); + EditorGUI.indentLevel--; + } + EditorGUILayout.EndFadeGroup(); + NativeSizeButtonGUI(); + + serializedObject.ApplyModifiedProperties(); + } + + void SetShowNativeSize(bool instant) + { + Image.Type type = (Image.Type)m_Type.enumValueIndex; + bool showNativeSize = (type == Image.Type.Simple || type == Image.Type.Filled) && m_Sprite.objectReferenceValue != null; + base.SetShowNativeSize(showNativeSize, instant); + } + + /// + /// Draw the atlas and Image selection fields. + /// + + protected void SpriteGUI() + { + EditorGUI.BeginChangeCheck(); + EditorGUILayout.PropertyField(m_Sprite, m_SpriteContent); + if (EditorGUI.EndChangeCheck()) + { + var newSprite = m_Sprite.objectReferenceValue as Sprite; + if (newSprite) + { + Image.Type oldType = (Image.Type)m_Type.enumValueIndex; + if (newSprite.border.SqrMagnitude() > 0) + { + m_Type.enumValueIndex = (int)Image.Type.Sliced; + } + else if (oldType == Image.Type.Sliced) + { + m_Type.enumValueIndex = (int)Image.Type.Simple; + } + } + } + } + + /// + /// Sprites's custom properties based on the type. + /// + + protected void TypeGUI() + { + EditorGUILayout.PropertyField(m_Type, m_SpriteTypeContent); + + ++EditorGUI.indentLevel; + { + Image.Type typeEnum = (Image.Type)m_Type.enumValueIndex; + + bool showSlicedOrTiled = (!m_Type.hasMultipleDifferentValues && (typeEnum == Image.Type.Sliced || typeEnum == Image.Type.Tiled)); + if (showSlicedOrTiled && targets.Length > 1) + showSlicedOrTiled = targets.Select(obj => obj as Image).All(img => img.hasBorder); + + m_ShowSlicedOrTiled.target = showSlicedOrTiled; + m_ShowSliced.target = (showSlicedOrTiled && !m_Type.hasMultipleDifferentValues && typeEnum == Image.Type.Sliced); + m_ShowTiled.target = (showSlicedOrTiled && !m_Type.hasMultipleDifferentValues && typeEnum == Image.Type.Tiled); + m_ShowFilled.target = (!m_Type.hasMultipleDifferentValues && typeEnum == Image.Type.Filled); + + Image image = target as Image; + if (EditorGUILayout.BeginFadeGroup(m_ShowSlicedOrTiled.faded)) + { + if (image.hasBorder) + EditorGUILayout.PropertyField(m_FillCenter); + } + EditorGUILayout.EndFadeGroup(); + + if (EditorGUILayout.BeginFadeGroup(m_ShowSliced.faded)) + { + if (image.sprite != null && !image.hasBorder) + EditorGUILayout.HelpBox("This Image doesn't have a border.", MessageType.Warning); + } + EditorGUILayout.EndFadeGroup(); + + if (EditorGUILayout.BeginFadeGroup(m_ShowTiled.faded)) + { + if (image.sprite != null && !image.hasBorder && (image.sprite.texture.wrapMode != TextureWrapMode.Repeat || image.sprite.packed)) + EditorGUILayout.HelpBox("It looks like you want to tile a sprite with no border. It would be more efficient to convert the Sprite to an Advanced texture, clear the Packing tag and set the Wrap mode to Repeat.", MessageType.Warning); + } + EditorGUILayout.EndFadeGroup(); + + if (EditorGUILayout.BeginFadeGroup(m_ShowFilled.faded)) + { + EditorGUI.BeginChangeCheck(); + EditorGUILayout.PropertyField(m_FillMethod); + if (EditorGUI.EndChangeCheck()) + { + m_FillOrigin.intValue = 0; + } + switch ((Image.FillMethod)m_FillMethod.enumValueIndex) + { + case Image.FillMethod.Horizontal: + m_FillOrigin.intValue = (int)(Image.OriginHorizontal)EditorGUILayout.EnumPopup("Fill Origin", (Image.OriginHorizontal)m_FillOrigin.intValue); + break; + case Image.FillMethod.Vertical: + m_FillOrigin.intValue = (int)(Image.OriginVertical)EditorGUILayout.EnumPopup("Fill Origin", (Image.OriginVertical)m_FillOrigin.intValue); + break; + case Image.FillMethod.Radial90: + m_FillOrigin.intValue = (int)(Image.Origin90)EditorGUILayout.EnumPopup("Fill Origin", (Image.Origin90)m_FillOrigin.intValue); + break; + case Image.FillMethod.Radial180: + m_FillOrigin.intValue = (int)(Image.Origin180)EditorGUILayout.EnumPopup("Fill Origin", (Image.Origin180)m_FillOrigin.intValue); + break; + case Image.FillMethod.Radial360: + m_FillOrigin.intValue = (int)(Image.Origin360)EditorGUILayout.EnumPopup("Fill Origin", (Image.Origin360)m_FillOrigin.intValue); + break; + } + EditorGUILayout.PropertyField(m_FillAmount); + if ((Image.FillMethod)m_FillMethod.enumValueIndex > Image.FillMethod.Vertical) + { + EditorGUILayout.PropertyField(m_FillClockwise, m_ClockwiseContent); + } + } + EditorGUILayout.EndFadeGroup(); + } + --EditorGUI.indentLevel; + } + + /// + /// All graphics have a preview. + /// + + public override bool HasPreviewGUI() { return true; } + + /// + /// Draw the Image preview. + /// + + public override void OnPreviewGUI(Rect rect, GUIStyle background) + { + Image image = target as Image; + if (image == null) return; + + Sprite sf = image.sprite; + if (sf == null) return; + + SpriteDrawUtility.DrawSprite(sf, rect, image.canvasRenderer.GetColor()); + } + + /// + /// Info String drawn at the bottom of the Preview + /// + + public override string GetInfoString() + { + Image image = target as Image; + Sprite sprite = image.sprite; + + int x = (sprite != null) ? Mathf.RoundToInt(sprite.rect.width) : 0; + int y = (sprite != null) ? Mathf.RoundToInt(sprite.rect.height) : 0; + + return string.Format("Image Size: {0}x{1}", x, y); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/ImageEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/ImageEditor.cs.meta new file mode 100644 index 0000000..db137d4 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/ImageEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 8c5c2197b06fed749be6adac4f6a0c1c +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/InputFieldEditor.cs b/Assets/uGUI-2017.1/Editor/UI/InputFieldEditor.cs new file mode 100644 index 0000000..f100f07 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/InputFieldEditor.cs @@ -0,0 +1,139 @@ +using UnityEditor.AnimatedValues; +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(InputField), true)] + public class InputFieldEditor : SelectableEditor + { + SerializedProperty m_TextComponent; + SerializedProperty m_Text; + SerializedProperty m_ContentType; + SerializedProperty m_LineType; + SerializedProperty m_InputType; + SerializedProperty m_CharacterValidation; + SerializedProperty m_KeyboardType; + SerializedProperty m_CharacterLimit; + SerializedProperty m_CaretBlinkRate; + SerializedProperty m_CaretWidth; + SerializedProperty m_CaretColor; + SerializedProperty m_CustomCaretColor; + SerializedProperty m_SelectionColor; + SerializedProperty m_HideMobileInput; + SerializedProperty m_Placeholder; + SerializedProperty m_OnValueChanged; + SerializedProperty m_OnEndEdit; + SerializedProperty m_ReadOnly; + + AnimBool m_CustomColor; + + protected override void OnEnable() + { + base.OnEnable(); + m_TextComponent = serializedObject.FindProperty("m_TextComponent"); + m_Text = serializedObject.FindProperty("m_Text"); + m_ContentType = serializedObject.FindProperty("m_ContentType"); + m_LineType = serializedObject.FindProperty("m_LineType"); + m_InputType = serializedObject.FindProperty("m_InputType"); + m_CharacterValidation = serializedObject.FindProperty("m_CharacterValidation"); + m_KeyboardType = serializedObject.FindProperty("m_KeyboardType"); + m_CharacterLimit = serializedObject.FindProperty("m_CharacterLimit"); + m_CaretBlinkRate = serializedObject.FindProperty("m_CaretBlinkRate"); + m_CaretWidth = serializedObject.FindProperty("m_CaretWidth"); + m_CaretColor = serializedObject.FindProperty("m_CaretColor"); + m_CustomCaretColor = serializedObject.FindProperty("m_CustomCaretColor"); + m_SelectionColor = serializedObject.FindProperty("m_SelectionColor"); + m_HideMobileInput = serializedObject.FindProperty("m_HideMobileInput"); + m_Placeholder = serializedObject.FindProperty("m_Placeholder"); + m_OnValueChanged = serializedObject.FindProperty("m_OnValueChanged"); + m_OnEndEdit = serializedObject.FindProperty("m_OnEndEdit"); + m_ReadOnly = serializedObject.FindProperty("m_ReadOnly"); + + m_CustomColor = new AnimBool(m_CustomCaretColor.boolValue); + m_CustomColor.valueChanged.AddListener(Repaint); + } + + protected override void OnDisable() + { + base.OnDisable(); + m_CustomColor.valueChanged.RemoveListener(Repaint); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + base.OnInspectorGUI(); + + EditorGUILayout.Space(); + + EditorGUILayout.PropertyField(m_TextComponent); + + if (m_TextComponent != null && m_TextComponent.objectReferenceValue != null) + { + Text text = m_TextComponent.objectReferenceValue as Text; + if (text.supportRichText) + { + EditorGUILayout.HelpBox("Using Rich Text with input is unsupported.", MessageType.Warning); + } + } + + using (new EditorGUI.DisabledScope(m_TextComponent == null || m_TextComponent.objectReferenceValue == null)) + { + EditorGUILayout.PropertyField(m_Text); + EditorGUILayout.PropertyField(m_CharacterLimit); + + EditorGUILayout.Space(); + + EditorGUILayout.PropertyField(m_ContentType); + if (!m_ContentType.hasMultipleDifferentValues) + { + EditorGUI.indentLevel++; + + if (m_ContentType.enumValueIndex == (int)InputField.ContentType.Standard || + m_ContentType.enumValueIndex == (int)InputField.ContentType.Autocorrected || + m_ContentType.enumValueIndex == (int)InputField.ContentType.Custom) + EditorGUILayout.PropertyField(m_LineType); + + if (m_ContentType.enumValueIndex == (int)InputField.ContentType.Custom) + { + EditorGUILayout.PropertyField(m_InputType); + EditorGUILayout.PropertyField(m_KeyboardType); + EditorGUILayout.PropertyField(m_CharacterValidation); + } + + EditorGUI.indentLevel--; + } + + EditorGUILayout.Space(); + + EditorGUILayout.PropertyField(m_Placeholder); + EditorGUILayout.PropertyField(m_CaretBlinkRate); + EditorGUILayout.PropertyField(m_CaretWidth); + + EditorGUILayout.PropertyField(m_CustomCaretColor); + + m_CustomColor.target = m_CustomCaretColor.boolValue; + + if (EditorGUILayout.BeginFadeGroup(m_CustomColor.faded)) + { + EditorGUILayout.PropertyField(m_CaretColor); + } + EditorGUILayout.EndFadeGroup(); + + EditorGUILayout.PropertyField(m_SelectionColor); + EditorGUILayout.PropertyField(m_HideMobileInput); + EditorGUILayout.PropertyField(m_ReadOnly); + + EditorGUILayout.Space(); + + EditorGUILayout.PropertyField(m_OnValueChanged); + EditorGUILayout.PropertyField(m_OnEndEdit); + } + + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/InputFieldEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/InputFieldEditor.cs.meta new file mode 100644 index 0000000..961284b --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/InputFieldEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 2c23aeb09974d4c41b3e2157285f204c +timeCreated: 1602119378 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/InterceptedEventsPreview.cs b/Assets/uGUI-2017.1/Editor/UI/InterceptedEventsPreview.cs new file mode 100644 index 0000000..b02e37e --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/InterceptedEventsPreview.cs @@ -0,0 +1,304 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using UnityEngine; +using UnityEngine.Profiling; +using UnityEngine.EventSystems; + +namespace UnityEditor.Events +{ + [CustomPreview(typeof(GameObject))] + class InterceptedEventsPreview : ObjectPreview + { + protected class ComponentInterceptedEvents + { + public GUIContent componentName; + public int[] interceptedEvents; + } + + class Styles + { + public GUIStyle labelStyle = new GUIStyle(EditorStyles.label); + public GUIStyle componentName = new GUIStyle(EditorStyles.boldLabel); + + public Styles() + { + Color fontColor = new Color(0.7f, 0.7f, 0.7f); + labelStyle.padding.right += 20; + labelStyle.normal.textColor = fontColor; + labelStyle.active.textColor = fontColor; + labelStyle.focused.textColor = fontColor; + labelStyle.hover.textColor = fontColor; + labelStyle.onNormal.textColor = fontColor; + labelStyle.onActive.textColor = fontColor; + labelStyle.onFocused.textColor = fontColor; + labelStyle.onHover.textColor = fontColor; + + componentName.normal.textColor = fontColor; + componentName.active.textColor = fontColor; + componentName.focused.textColor = fontColor; + componentName.hover.textColor = fontColor; + componentName.onNormal.textColor = fontColor; + componentName.onActive.textColor = fontColor; + componentName.onFocused.textColor = fontColor; + componentName.onHover.textColor = fontColor; + } + } + + private Dictionary> m_TargetEvents; + private bool m_InterceptsAnyEvent = false; + private GUIContent m_Title; + private Styles m_Styles = new Styles(); + + public override void Initialize(UnityEngine.Object[] targets) + { + Profiler.BeginSample("ComponentInterceptedEvents.Initialize"); + + base.Initialize(targets); + m_TargetEvents = new Dictionary>(targets.Count()); + m_InterceptsAnyEvent = false; + for (int i = 0; i < targets.Length; ++i) + { + GameObject go = targets[i] as GameObject; + List interceptedEvents = GetEventsInfo(go); + m_TargetEvents.Add(go, interceptedEvents); + if (interceptedEvents.Any()) + m_InterceptsAnyEvent = true; + } + Profiler.EndSample(); + } + + public override GUIContent GetPreviewTitle() + { + if (m_Title == null) + { + m_Title = new GUIContent("Intercepted Events"); + } + return m_Title; + } + + public override bool HasPreviewGUI() + { + return m_TargetEvents != null && m_InterceptsAnyEvent; + } + + public override void OnPreviewGUI(Rect r, GUIStyle background) + { + if (Event.current.type != EventType.Repaint) + return; + Profiler.BeginSample("InterceptedEventsPreview.OnPreviewGUI"); + + + if (m_Styles == null) + m_Styles = new Styles(); + + Vector2 maxEventLabelSize = Vector2.zero; + int totalInterceptedEvents = 0; + + List componentIncerceptedEvents = m_TargetEvents[target as GameObject]; + + // Find out the maximum size needed for any given label. + foreach (ComponentInterceptedEvents componentInterceptedEvents in componentIncerceptedEvents) + { + foreach (int eventIndex in componentInterceptedEvents.interceptedEvents) + { + GUIContent eventContent = s_PossibleEvents[eventIndex]; + ++totalInterceptedEvents; + Vector2 labelSize = m_Styles.labelStyle.CalcSize(eventContent); + if (maxEventLabelSize.x < labelSize.x) + { + maxEventLabelSize.x = labelSize.x; + } + if (maxEventLabelSize.y < labelSize.y) + { + maxEventLabelSize.y = labelSize.y; + } + } + } + + // Apply padding + RectOffset previewPadding = new RectOffset(-5, -5, -5, -5); + r = previewPadding.Add(r); + + // Figure out how many rows and columns we can/should have + int columns = Mathf.Max(Mathf.FloorToInt(r.width / maxEventLabelSize.x), 1); + int rows = Mathf.Max(totalInterceptedEvents / columns, 1) + componentIncerceptedEvents.Count; + + // Centering + float initialX = r.x + Mathf.Max(0, (r.width - (maxEventLabelSize.x * columns)) / 2); + float initialY = r.y + Mathf.Max(0, (r.height - (maxEventLabelSize.y * rows)) / 2); + + Rect labelRect = new Rect(initialX, initialY, maxEventLabelSize.x, maxEventLabelSize.y); + int currentColumn = 0; + foreach (ComponentInterceptedEvents componentInterceptedEvents in componentIncerceptedEvents) + { + GUI.Label(labelRect, componentInterceptedEvents.componentName, m_Styles.componentName); + labelRect.y += labelRect.height; + labelRect.x = initialX; + foreach (int eventIndex in componentInterceptedEvents.interceptedEvents) + { + GUIContent eventContent = s_PossibleEvents[eventIndex]; + GUI.Label(labelRect, eventContent, m_Styles.labelStyle); + if (currentColumn < columns - 1) + { + labelRect.x += labelRect.width; + } + else + { + labelRect.y += labelRect.height; + labelRect.x = initialX; + } + + currentColumn = (currentColumn + 1) % columns; + } + + if (labelRect.x != initialX) + { + labelRect.y += labelRect.height; + labelRect.x = initialX; + } + } + Profiler.EndSample(); + } + + //Lookup cache to avoid recalculating which types uses which events: + //Caches all interfaces that inherit from IEventSystemHandler + static List s_EventSystemInterfaces = null; + //Caches all GUIContents in a single list to avoid creating too much GUIContent and strings. + private static List s_PossibleEvents = null; + //Caches all events used by each interface + static Dictionary> s_InterfaceEventSystemEvents = null; + //Caches each concrete type and it's events + static readonly Dictionary s_ComponentEvents2 = new Dictionary(); + + + protected static List GetEventsInfo(GameObject gameObject) + { + InitializeEvetnsInterfaceCacheIfNeeded(); + + List componentEvents = new List(); + + MonoBehaviour[] mbs = gameObject.GetComponents(); + + for (int i = 0, imax = mbs.Length; i < imax; ++i) + { + ComponentInterceptedEvents componentEvent = null; + + MonoBehaviour mb = mbs[i]; + if (mb == null) + continue; + + Type type = mb.GetType(); + + if (!s_ComponentEvents2.ContainsKey(type)) + { + List events = null; + Profiler.BeginSample("ComponentInterceptedEvents.GetEventsInfo.NewType"); + if (typeof(IEventSystemHandler).IsAssignableFrom(type)) + { + for (int index = 0; index < s_EventSystemInterfaces.Count; index++) + { + var eventInterface = s_EventSystemInterfaces[index]; + if (!eventInterface.IsAssignableFrom(type)) + continue; + + if (events == null) + events = new List(); + + events.AddRange(s_InterfaceEventSystemEvents[eventInterface]); + } + } + + if (events != null) + { + componentEvent = new ComponentInterceptedEvents(); + componentEvent.componentName = new GUIContent(type.Name); + componentEvent.interceptedEvents = events.OrderBy(index => s_PossibleEvents[index].text).ToArray(); + } + s_ComponentEvents2.Add(type, componentEvent); + + Profiler.EndSample(); + } + else + { + componentEvent = s_ComponentEvents2[type]; + } + + + if (componentEvent != null) + { + componentEvents.Add(componentEvent); + } + } + + return componentEvents; + } + + private static void InitializeEvetnsInterfaceCacheIfNeeded() + { + if (s_EventSystemInterfaces != null) + return; + + s_EventSystemInterfaces = new List(); + s_PossibleEvents = new List(); + s_InterfaceEventSystemEvents = new Dictionary>(); + + foreach (var type in GetAccessibleTypesInLoadedAssemblies()) + { + if (!type.IsInterface) + continue; + + if (!typeof(IEventSystemHandler).IsAssignableFrom(type)) + continue; + + s_EventSystemInterfaces.Add(type); + List eventIndexList = new List(); + + MethodInfo[] methodInfos = type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); + for (int mi = 0; mi < methodInfos.Length; mi++) + { + MethodInfo methodInfo = methodInfos[mi]; + eventIndexList.Add(s_PossibleEvents.Count); + s_PossibleEvents.Add(new GUIContent(methodInfo.Name)); + } + s_InterfaceEventSystemEvents.Add(type, eventIndexList); + } + } + + private static IEnumerable GetAccessibleTypesInLoadedAssemblies() + { + var assemblies = AppDomain.CurrentDomain.GetAssemblies(); + for (var i = 0; i < assemblies.Length; ++i) + { + Type[] types; + var assembly = assemblies[i]; + + if (assembly == null) + continue; + + try + { + types = assembly.GetTypes(); + } + catch (ReflectionTypeLoadException e) + { + // assembly.GetTypes() might fail in case the Assembly cannot resolve all its references, + // or in case it was built targetting a newer version of .NET. + // In case the resolution fails for some types, we can still access the ones that have been + // properly loaded. + types = e.Types; + } + + for (var j = 0; j < types.Length; ++j) + { + var type = types[j]; + if (type == null) + continue; + + yield return type; + } + } + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/InterceptedEventsPreview.cs.meta b/Assets/uGUI-2017.1/Editor/UI/InterceptedEventsPreview.cs.meta new file mode 100644 index 0000000..6b1ac00 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/InterceptedEventsPreview.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: d8a1fb8949afd2b4a89786a167d4efbe +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/LayoutElementEditor.cs b/Assets/uGUI-2017.1/Editor/UI/LayoutElementEditor.cs new file mode 100644 index 0000000..ac80f5a --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/LayoutElementEditor.cs @@ -0,0 +1,102 @@ +using UnityEngine; +using UnityEngine.UI; +using UnityEditorInternal; +using UnityEditor.AnimatedValues; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(LayoutElement), true)] + [CanEditMultipleObjects] + public class LayoutElementEditor : Editor + { + SerializedProperty m_IgnoreLayout; + SerializedProperty m_MinWidth; + SerializedProperty m_MinHeight; + SerializedProperty m_PreferredWidth; + SerializedProperty m_PreferredHeight; + SerializedProperty m_FlexibleWidth; + SerializedProperty m_FlexibleHeight; + SerializedProperty m_LayoutPriority; + + protected virtual void OnEnable() + { + m_IgnoreLayout = serializedObject.FindProperty("m_IgnoreLayout"); + m_MinWidth = serializedObject.FindProperty("m_MinWidth"); + m_MinHeight = serializedObject.FindProperty("m_MinHeight"); + m_PreferredWidth = serializedObject.FindProperty("m_PreferredWidth"); + m_PreferredHeight = serializedObject.FindProperty("m_PreferredHeight"); + m_FlexibleWidth = serializedObject.FindProperty("m_FlexibleWidth"); + m_FlexibleHeight = serializedObject.FindProperty("m_FlexibleHeight"); + m_LayoutPriority = serializedObject.FindProperty("m_LayoutPriority"); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + EditorGUILayout.PropertyField(m_IgnoreLayout); + + if (!m_IgnoreLayout.boolValue) + { + EditorGUILayout.Space(); + + LayoutElementField(m_MinWidth, 0); + LayoutElementField(m_MinHeight, 0); + LayoutElementField(m_PreferredWidth, t => t.rect.width); + LayoutElementField(m_PreferredHeight, t => t.rect.height); + LayoutElementField(m_FlexibleWidth, 1); + LayoutElementField(m_FlexibleHeight, 1); + } + + EditorGUILayout.PropertyField(m_LayoutPriority); + + serializedObject.ApplyModifiedProperties(); + } + + void LayoutElementField(SerializedProperty property, float defaultValue) + { + LayoutElementField(property, _ => defaultValue); + } + + void LayoutElementField(SerializedProperty property, System.Func defaultValue) + { + Rect position = EditorGUILayout.GetControlRect(); + + // Label + GUIContent label = EditorGUI.BeginProperty(position, null, property); + + // Rects + Rect fieldPosition = EditorGUI.PrefixLabel(position, label); + + Rect toggleRect = fieldPosition; + toggleRect.width = 16; + + Rect floatFieldRect = fieldPosition; + floatFieldRect.xMin += 16; + + // Checkbox + EditorGUI.BeginChangeCheck(); + bool enabled = EditorGUI.ToggleLeft(toggleRect, GUIContent.none, property.floatValue >= 0); + if (EditorGUI.EndChangeCheck()) + { + // This could be made better to set all of the targets to their initial width, but mimizing code change for now + property.floatValue = (enabled ? defaultValue((target as LayoutElement).transform as RectTransform) : -1); + } + + if (!property.hasMultipleDifferentValues && property.floatValue >= 0) + { + // Float field + EditorGUIUtility.labelWidth = 4; // Small invisible label area for drag zone functionality + EditorGUI.BeginChangeCheck(); + float newValue = EditorGUI.FloatField(floatFieldRect, new GUIContent(" "), property.floatValue); + if (EditorGUI.EndChangeCheck()) + { + property.floatValue = Mathf.Max(0, newValue); + } + EditorGUIUtility.labelWidth = 0; + } + + EditorGUI.EndProperty(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/LayoutElementEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/LayoutElementEditor.cs.meta new file mode 100644 index 0000000..8744d62 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/LayoutElementEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ffcef66c44c6c174eb838804dcaab7f0 +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/LayoutPropertiesPreview.cs b/Assets/uGUI-2017.1/Editor/UI/LayoutPropertiesPreview.cs new file mode 100644 index 0000000..6f93c98 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/LayoutPropertiesPreview.cs @@ -0,0 +1,123 @@ +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.Events +{ + [CustomPreview(typeof(GameObject))] + class LayoutPropertiesPreview : ObjectPreview + { + private const float kLabelWidth = 110; + private const float kValueWidth = 100; + + class Styles + { + public GUIStyle labelStyle = new GUIStyle(EditorStyles.label); + public GUIStyle headerStyle = new GUIStyle(EditorStyles.boldLabel); + + public Styles() + { + Color fontColor = new Color(0.7f, 0.7f, 0.7f); + labelStyle.padding.right += 4; + labelStyle.normal.textColor = fontColor; + headerStyle.padding.right += 4; + headerStyle.normal.textColor = fontColor; + } + } + + private GUIContent m_Title; + private Styles m_Styles = new Styles(); + + public override void Initialize(UnityEngine.Object[] targets) + { + base.Initialize(targets); + } + + public override GUIContent GetPreviewTitle() + { + if (m_Title == null) + { + m_Title = new GUIContent("Layout Properties"); + } + return m_Title; + } + + public override bool HasPreviewGUI() + { + GameObject go = target as GameObject; + if (!go) + return false; + return go.GetComponent(typeof(ILayoutElement)) != null; + } + + public override void OnPreviewGUI(Rect r, GUIStyle background) + { + if (Event.current.type != EventType.Repaint) + return; + + if (m_Styles == null) + m_Styles = new Styles(); + + GameObject go = target as GameObject; + RectTransform rect = go.transform as RectTransform; + if (rect == null) + return; + + // Apply padding + RectOffset previewPadding = new RectOffset(-5, -5, -5, -5); + r = previewPadding.Add(r); + + // Prepare rects for columns + r.height = EditorGUIUtility.singleLineHeight; + Rect labelRect = r; + Rect valueRect = r; + Rect sourceRect = r; + labelRect.width = kLabelWidth; + valueRect.xMin += kLabelWidth; + valueRect.width = kValueWidth; + sourceRect.xMin += kLabelWidth + kValueWidth; + + // Headers + GUI.Label(labelRect, "Property", m_Styles.headerStyle); + GUI.Label(valueRect, "Value", m_Styles.headerStyle); + GUI.Label(sourceRect, "Source", m_Styles.headerStyle); + labelRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + valueRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + sourceRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + + // Prepare reusable variable for out argument + ILayoutElement source = null; + + // Show properties + + ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Min Width", LayoutUtility.GetLayoutProperty(rect, e => e.minWidth, 0, out source).ToString(), source); + ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Min Height", LayoutUtility.GetLayoutProperty(rect, e => e.minHeight, 0, out source).ToString(), source); + ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Preferred Width", LayoutUtility.GetLayoutProperty(rect, e => e.preferredWidth, 0, out source).ToString(), source); + ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Preferred Height", LayoutUtility.GetLayoutProperty(rect, e => e.preferredHeight, 0, out source).ToString(), source); + + float flexible = 0; + + flexible = LayoutUtility.GetLayoutProperty(rect, e => e.flexibleWidth, 0, out source); + ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Flexible Width", flexible > 0 ? ("enabled (" + flexible.ToString() + ")") : "disabled", source); + flexible = LayoutUtility.GetLayoutProperty(rect, e => e.flexibleHeight, 0, out source); + ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Flexible Height", flexible > 0 ? ("enabled (" + flexible.ToString() + ")") : "disabled", source); + + if (!rect.GetComponent()) + { + Rect noteRect = new Rect(labelRect.x, labelRect.y + 10, r.width, EditorGUIUtility.singleLineHeight); + GUI.Label(noteRect, "Add a LayoutElement to override values.", m_Styles.labelStyle); + } + } + + private void ShowProp(ref Rect labelRect, ref Rect valueRect, ref Rect sourceRect, string label, string value, ILayoutElement source) + { + GUI.Label(labelRect, label, m_Styles.labelStyle); + GUI.Label(valueRect, value, m_Styles.labelStyle); + GUI.Label(sourceRect, source == null ? "none" : source.GetType().Name, m_Styles.labelStyle); + labelRect.y += EditorGUIUtility.singleLineHeight; + valueRect.y += EditorGUIUtility.singleLineHeight; + sourceRect.y += EditorGUIUtility.singleLineHeight; + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/LayoutPropertiesPreview.cs.meta b/Assets/uGUI-2017.1/Editor/UI/LayoutPropertiesPreview.cs.meta new file mode 100644 index 0000000..20eb908 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/LayoutPropertiesPreview.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: f103303bf9c7f654492f77f00631a1be +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/MaskEditor.cs b/Assets/uGUI-2017.1/Editor/UI/MaskEditor.cs new file mode 100644 index 0000000..8a1a486 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/MaskEditor.cs @@ -0,0 +1,28 @@ +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(Mask), true)] + [CanEditMultipleObjects] + public class MaskEditor : Editor + { + SerializedProperty m_ShowMaskGraphic; + + protected virtual void OnEnable() + { + m_ShowMaskGraphic = serializedObject.FindProperty("m_ShowMaskGraphic"); + } + + public override void OnInspectorGUI() + { + var graphic = (target as Mask).GetComponent(); + + if (graphic && !graphic.IsActive()) + EditorGUILayout.HelpBox("Masking disabled due to Graphic component being disabled.", MessageType.Warning); + + serializedObject.Update(); + EditorGUILayout.PropertyField(m_ShowMaskGraphic); + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/MaskEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/MaskEditor.cs.meta new file mode 100644 index 0000000..925cbdf --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/MaskEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 764bee73159c4d443a00c1c3788a3be9 +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/MenuOptions.cs b/Assets/uGUI-2017.1/Editor/UI/MenuOptions.cs new file mode 100644 index 0000000..94d0016 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/MenuOptions.cs @@ -0,0 +1,282 @@ +using UnityEngine; +using UnityEngine.EventSystems; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + /// + /// This script adds the UI menu options to the Unity Editor. + /// + + static internal class MenuOptions + { + private const string kUILayerName = "UI"; + + private const string kStandardSpritePath = "UI/Skin/UISprite.psd"; + private const string kBackgroundSpritePath = "UI/Skin/Background.psd"; + private const string kInputFieldBackgroundPath = "UI/Skin/InputFieldBackground.psd"; + private const string kKnobPath = "UI/Skin/Knob.psd"; + private const string kCheckmarkPath = "UI/Skin/Checkmark.psd"; + private const string kDropdownArrowPath = "UI/Skin/DropdownArrow.psd"; + private const string kMaskPath = "UI/Skin/UIMask.psd"; + + static private DefaultControls.Resources s_StandardResources; + + static private DefaultControls.Resources GetStandardResources() + { + if (s_StandardResources.standard == null) + { + s_StandardResources.standard = AssetDatabase.GetBuiltinExtraResource(kStandardSpritePath); + s_StandardResources.background = AssetDatabase.GetBuiltinExtraResource(kBackgroundSpritePath); + s_StandardResources.inputField = AssetDatabase.GetBuiltinExtraResource(kInputFieldBackgroundPath); + s_StandardResources.knob = AssetDatabase.GetBuiltinExtraResource(kKnobPath); + s_StandardResources.checkmark = AssetDatabase.GetBuiltinExtraResource(kCheckmarkPath); + s_StandardResources.dropdown = AssetDatabase.GetBuiltinExtraResource(kDropdownArrowPath); + s_StandardResources.mask = AssetDatabase.GetBuiltinExtraResource(kMaskPath); + } + return s_StandardResources; + } + + private static void SetPositionVisibleinSceneView(RectTransform canvasRTransform, RectTransform itemTransform) + { + // Find the best scene view + SceneView sceneView = SceneView.lastActiveSceneView; + if (sceneView == null && SceneView.sceneViews.Count > 0) + sceneView = SceneView.sceneViews[0] as SceneView; + + // Couldn't find a SceneView. Don't set position. + if (sceneView == null || sceneView.camera == null) + return; + + // Create world space Plane from canvas position. + Vector2 localPlanePosition; + Camera camera = sceneView.camera; + Vector3 position = Vector3.zero; + if (RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRTransform, new Vector2(camera.pixelWidth / 2, camera.pixelHeight / 2), camera, out localPlanePosition)) + { + // Adjust for canvas pivot + localPlanePosition.x = localPlanePosition.x + canvasRTransform.sizeDelta.x * canvasRTransform.pivot.x; + localPlanePosition.y = localPlanePosition.y + canvasRTransform.sizeDelta.y * canvasRTransform.pivot.y; + + localPlanePosition.x = Mathf.Clamp(localPlanePosition.x, 0, canvasRTransform.sizeDelta.x); + localPlanePosition.y = Mathf.Clamp(localPlanePosition.y, 0, canvasRTransform.sizeDelta.y); + + // Adjust for anchoring + position.x = localPlanePosition.x - canvasRTransform.sizeDelta.x * itemTransform.anchorMin.x; + position.y = localPlanePosition.y - canvasRTransform.sizeDelta.y * itemTransform.anchorMin.y; + + Vector3 minLocalPosition; + minLocalPosition.x = canvasRTransform.sizeDelta.x * (0 - canvasRTransform.pivot.x) + itemTransform.sizeDelta.x * itemTransform.pivot.x; + minLocalPosition.y = canvasRTransform.sizeDelta.y * (0 - canvasRTransform.pivot.y) + itemTransform.sizeDelta.y * itemTransform.pivot.y; + + Vector3 maxLocalPosition; + maxLocalPosition.x = canvasRTransform.sizeDelta.x * (1 - canvasRTransform.pivot.x) - itemTransform.sizeDelta.x * itemTransform.pivot.x; + maxLocalPosition.y = canvasRTransform.sizeDelta.y * (1 - canvasRTransform.pivot.y) - itemTransform.sizeDelta.y * itemTransform.pivot.y; + + position.x = Mathf.Clamp(position.x, minLocalPosition.x, maxLocalPosition.x); + position.y = Mathf.Clamp(position.y, minLocalPosition.y, maxLocalPosition.y); + } + + itemTransform.anchoredPosition = position; + itemTransform.localRotation = Quaternion.identity; + itemTransform.localScale = Vector3.one; + } + + private static void PlaceUIElementRoot(GameObject element, MenuCommand menuCommand) + { + GameObject parent = menuCommand.context as GameObject; + if (parent == null || parent.GetComponentInParent() == null) + { + parent = GetOrCreateCanvasGameObject(); + } + + string uniqueName = GameObjectUtility.GetUniqueNameForSibling(parent.transform, element.name); + element.name = uniqueName; + Undo.RegisterCreatedObjectUndo(element, "Create " + element.name); + Undo.SetTransformParent(element.transform, parent.transform, "Parent " + element.name); + GameObjectUtility.SetParentAndAlign(element, parent); + if (parent != menuCommand.context) // not a context click, so center in sceneview + SetPositionVisibleinSceneView(parent.GetComponent(), element.GetComponent()); + + Selection.activeGameObject = element; + } + + // Graphic elements + + [MenuItem("GameObject/UI/Text", false, 2000)] + static public void AddText(MenuCommand menuCommand) + { + GameObject go = DefaultControls.CreateText(GetStandardResources()); + PlaceUIElementRoot(go, menuCommand); + } + + [MenuItem("GameObject/UI/Image", false, 2001)] + static public void AddImage(MenuCommand menuCommand) + { + GameObject go = DefaultControls.CreateImage(GetStandardResources()); + PlaceUIElementRoot(go, menuCommand); + } + + [MenuItem("GameObject/UI/Raw Image", false, 2002)] + static public void AddRawImage(MenuCommand menuCommand) + { + GameObject go = DefaultControls.CreateRawImage(GetStandardResources()); + PlaceUIElementRoot(go, menuCommand); + } + + // Controls + + // Button and toggle are controls you just click on. + + [MenuItem("GameObject/UI/Button", false, 2030)] + static public void AddButton(MenuCommand menuCommand) + { + GameObject go = DefaultControls.CreateButton(GetStandardResources()); + PlaceUIElementRoot(go, menuCommand); + } + + [MenuItem("GameObject/UI/Toggle", false, 2031)] + static public void AddToggle(MenuCommand menuCommand) + { + GameObject go = DefaultControls.CreateToggle(GetStandardResources()); + PlaceUIElementRoot(go, menuCommand); + } + + // Slider and Scrollbar modify a number + + [MenuItem("GameObject/UI/Slider", false, 2033)] + static public void AddSlider(MenuCommand menuCommand) + { + GameObject go = DefaultControls.CreateSlider(GetStandardResources()); + PlaceUIElementRoot(go, menuCommand); + } + + [MenuItem("GameObject/UI/Scrollbar", false, 2034)] + static public void AddScrollbar(MenuCommand menuCommand) + { + GameObject go = DefaultControls.CreateScrollbar(GetStandardResources()); + PlaceUIElementRoot(go, menuCommand); + } + + // More advanced controls below + + [MenuItem("GameObject/UI/Dropdown", false, 2035)] + static public void AddDropdown(MenuCommand menuCommand) + { + GameObject go = DefaultControls.CreateDropdown(GetStandardResources()); + PlaceUIElementRoot(go, menuCommand); + } + + [MenuItem("GameObject/UI/Input Field", false, 2036)] + public static void AddInputField(MenuCommand menuCommand) + { + GameObject go = DefaultControls.CreateInputField(GetStandardResources()); + PlaceUIElementRoot(go, menuCommand); + } + + // Containers + + [MenuItem("GameObject/UI/Canvas", false, 2060)] + static public void AddCanvas(MenuCommand menuCommand) + { + var go = CreateNewUI(); + GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject); + if (go.transform.parent as RectTransform) + { + RectTransform rect = go.transform as RectTransform; + rect.anchorMin = Vector2.zero; + rect.anchorMax = Vector2.one; + rect.anchoredPosition = Vector2.zero; + rect.sizeDelta = Vector2.zero; + } + Selection.activeGameObject = go; + } + + [MenuItem("GameObject/UI/Panel", false, 2061)] + static public void AddPanel(MenuCommand menuCommand) + { + GameObject go = DefaultControls.CreatePanel(GetStandardResources()); + PlaceUIElementRoot(go, menuCommand); + + // Panel is special, we need to ensure there's no padding after repositioning. + RectTransform rect = go.GetComponent(); + rect.anchoredPosition = Vector2.zero; + rect.sizeDelta = Vector2.zero; + } + + [MenuItem("GameObject/UI/Scroll View", false, 2062)] + static public void AddScrollView(MenuCommand menuCommand) + { + GameObject go = DefaultControls.CreateScrollView(GetStandardResources()); + PlaceUIElementRoot(go, menuCommand); + } + + // Helper methods + + static public GameObject CreateNewUI() + { + // Root for the UI + var root = new GameObject("Canvas"); + root.layer = LayerMask.NameToLayer(kUILayerName); + Canvas canvas = root.AddComponent(); + canvas.renderMode = RenderMode.ScreenSpaceOverlay; + root.AddComponent(); + root.AddComponent(); + Undo.RegisterCreatedObjectUndo(root, "Create " + root.name); + + // if there is no event system add one... + CreateEventSystem(false); + return root; + } + + [MenuItem("GameObject/UI/Event System", false, 2100)] + public static void CreateEventSystem(MenuCommand menuCommand) + { + GameObject parent = menuCommand.context as GameObject; + CreateEventSystem(true, parent); + } + + private static void CreateEventSystem(bool select) + { + CreateEventSystem(select, null); + } + + private static void CreateEventSystem(bool select, GameObject parent) + { + var esys = Object.FindObjectOfType(); + if (esys == null) + { + var eventSystem = new GameObject("EventSystem"); + GameObjectUtility.SetParentAndAlign(eventSystem, parent); + esys = eventSystem.AddComponent(); + eventSystem.AddComponent(); + + Undo.RegisterCreatedObjectUndo(eventSystem, "Create " + eventSystem.name); + } + + if (select && esys != null) + { + Selection.activeGameObject = esys.gameObject; + } + } + + // Helper function that returns a Canvas GameObject; preferably a parent of the selection, or other existing Canvas. + static public GameObject GetOrCreateCanvasGameObject() + { + GameObject selectedGo = Selection.activeGameObject; + + // Try to find a gameobject that is the selected GO or one if its parents. + Canvas canvas = (selectedGo != null) ? selectedGo.GetComponentInParent() : null; + if (canvas != null && canvas.gameObject.activeInHierarchy) + return canvas.gameObject; + + // No canvas in selection or its parents? Then use just any canvas.. + canvas = Object.FindObjectOfType(typeof(Canvas)) as Canvas; + if (canvas != null && canvas.gameObject.activeInHierarchy) + return canvas.gameObject; + + // No canvas in the scene at all? Then create a new one. + return MenuOptions.CreateNewUI(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/MenuOptions.cs.meta b/Assets/uGUI-2017.1/Editor/UI/MenuOptions.cs.meta new file mode 100644 index 0000000..17aac1f --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/MenuOptions.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: a30d9ac75138f9e45811070c267b929d +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/PrefabLayoutRebuilder.cs b/Assets/uGUI-2017.1/Editor/UI/PrefabLayoutRebuilder.cs new file mode 100644 index 0000000..0f933da --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PrefabLayoutRebuilder.cs @@ -0,0 +1,24 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [InitializeOnLoad] + internal class PrefabLayoutRebuilder + { + static PrefabLayoutRebuilder() + { + PrefabUtility.prefabInstanceUpdated += OnPrefabInstanceUpdates; + } + + static void OnPrefabInstanceUpdates(GameObject instance) + { + if (instance) + { + RectTransform rect = instance.transform as RectTransform; + if (rect) + LayoutRebuilder.MarkLayoutForRebuild(rect); + } + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/PrefabLayoutRebuilder.cs.meta b/Assets/uGUI-2017.1/Editor/UI/PrefabLayoutRebuilder.cs.meta new file mode 100644 index 0000000..435b8d5 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PrefabLayoutRebuilder.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 258eff23cc7cc4a4888c4570caabda7c +timeCreated: 1602119377 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers.meta b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers.meta new file mode 100644 index 0000000..5514f30 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: f6033d0a1e14b0f4f81e73060756cf38 +folderAsset: yes +timeCreated: 1602119280 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/AnimationTriggersDrawer.cs b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/AnimationTriggersDrawer.cs new file mode 100644 index 0000000..67cab2e --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/AnimationTriggersDrawer.cs @@ -0,0 +1,33 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomPropertyDrawer(typeof(AnimationTriggers), true)] + public class AnimationTriggersDrawer : PropertyDrawer + { + public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label) + { + Rect drawRect = rect; + drawRect.height = EditorGUIUtility.singleLineHeight; + + SerializedProperty normalTrigger = prop.FindPropertyRelative("m_NormalTrigger"); + SerializedProperty higlightedTrigger = prop.FindPropertyRelative("m_HighlightedTrigger"); + SerializedProperty pressedTrigger = prop.FindPropertyRelative("m_PressedTrigger"); + SerializedProperty disabledTrigger = prop.FindPropertyRelative("m_DisabledTrigger"); + + EditorGUI.PropertyField(drawRect, normalTrigger); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, higlightedTrigger); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, pressedTrigger); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, disabledTrigger); + } + + public override float GetPropertyHeight(SerializedProperty prop, GUIContent label) + { + return 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing; + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/AnimationTriggersDrawer.cs.meta b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/AnimationTriggersDrawer.cs.meta new file mode 100644 index 0000000..f9df6cc --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/AnimationTriggersDrawer.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: c7e8a036dae779446aa880079e2fcd93 +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/ColorBlockDrawer.cs b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/ColorBlockDrawer.cs new file mode 100644 index 0000000..a471eeb --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/ColorBlockDrawer.cs @@ -0,0 +1,39 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomPropertyDrawer(typeof(ColorBlock), true)] + public class ColorBlockDrawer : PropertyDrawer + { + public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label) + { + Rect drawRect = rect; + drawRect.height = EditorGUIUtility.singleLineHeight; + + SerializedProperty normalColor = prop.FindPropertyRelative("m_NormalColor"); + SerializedProperty highlighted = prop.FindPropertyRelative("m_HighlightedColor"); + SerializedProperty pressedColor = prop.FindPropertyRelative("m_PressedColor"); + SerializedProperty disabledColor = prop.FindPropertyRelative("m_DisabledColor"); + SerializedProperty colorMultiplier = prop.FindPropertyRelative("m_ColorMultiplier"); + SerializedProperty fadeDuration = prop.FindPropertyRelative("m_FadeDuration"); + + EditorGUI.PropertyField(drawRect, normalColor); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, highlighted); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, pressedColor); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, disabledColor); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, colorMultiplier); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, fadeDuration); + } + + public override float GetPropertyHeight(SerializedProperty prop, GUIContent label) + { + return 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing; + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/ColorBlockDrawer.cs.meta b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/ColorBlockDrawer.cs.meta new file mode 100644 index 0000000..a7ac278 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/ColorBlockDrawer.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 94cd9d005e865c94faaef6f8213faecd +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/DropdownOptionListDrawer.cs b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/DropdownOptionListDrawer.cs new file mode 100644 index 0000000..662016c --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/DropdownOptionListDrawer.cs @@ -0,0 +1,59 @@ +using UnityEditorInternal; +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomPropertyDrawer(typeof(Dropdown.OptionDataList), true)] + class DropdownOptionListDrawer : PropertyDrawer + { + private ReorderableList m_ReorderableList; + + private void Init(SerializedProperty property) + { + if (m_ReorderableList != null) + return; + + SerializedProperty array = property.FindPropertyRelative("m_Options"); + + m_ReorderableList = new ReorderableList(property.serializedObject, array); + m_ReorderableList.drawElementCallback = DrawOptionData; + m_ReorderableList.drawHeaderCallback = DrawHeader; + m_ReorderableList.elementHeight += 16; + } + + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + Init(property); + + m_ReorderableList.DoList(position); + } + + private void DrawHeader(Rect rect) + { + GUI.Label(rect, "Options"); + } + + private void DrawOptionData(Rect rect, int index, bool isActive, bool isFocused) + { + SerializedProperty itemData = m_ReorderableList.serializedProperty.GetArrayElementAtIndex(index); + SerializedProperty itemText = itemData.FindPropertyRelative("m_Text"); + SerializedProperty itemImage = itemData.FindPropertyRelative("m_Image"); + + RectOffset offset = new RectOffset(0, 0, -1, -3); + rect = offset.Add(rect); + rect.height = EditorGUIUtility.singleLineHeight; + + EditorGUI.PropertyField(rect, itemText, GUIContent.none); + rect.y += EditorGUIUtility.singleLineHeight; + EditorGUI.PropertyField(rect, itemImage, GUIContent.none); + } + + public override float GetPropertyHeight(SerializedProperty property, GUIContent label) + { + Init(property); + + return m_ReorderableList.GetHeight(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/DropdownOptionListDrawer.cs.meta b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/DropdownOptionListDrawer.cs.meta new file mode 100644 index 0000000..21f09c2 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/DropdownOptionListDrawer.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 0b0e171e6b1b1d943b7da016b41a7f88 +timeCreated: 1602119377 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/FontDataDrawer.cs b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/FontDataDrawer.cs new file mode 100644 index 0000000..5db2387 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/FontDataDrawer.cs @@ -0,0 +1,512 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomPropertyDrawer(typeof(FontData), true)] + public class FontDataDrawer : PropertyDrawer + { + static private class Styles + { + public static GUIStyle alignmentButtonLeft = new GUIStyle(EditorStyles.miniButtonLeft); + public static GUIStyle alignmentButtonMid = new GUIStyle(EditorStyles.miniButtonMid); + public static GUIStyle alignmentButtonRight = new GUIStyle(EditorStyles.miniButtonRight); + + public static GUIContent m_EncodingContent; + + public static GUIContent m_LeftAlignText; + public static GUIContent m_CenterAlignText; + public static GUIContent m_RightAlignText; + public static GUIContent m_TopAlignText; + public static GUIContent m_MiddleAlignText; + public static GUIContent m_BottomAlignText; + + public static GUIContent m_LeftAlignTextActive; + public static GUIContent m_CenterAlignTextActive; + public static GUIContent m_RightAlignTextActive; + public static GUIContent m_TopAlignTextActive; + public static GUIContent m_MiddleAlignTextActive; + public static GUIContent m_BottomAlignTextActive; + + static Styles() + { + m_EncodingContent = new GUIContent("Rich Text", "Use emoticons and colors"); + + // Horizontal Alignment Icons + m_LeftAlignText = EditorGUIUtility.IconContent(@"GUISystem/align_horizontally_left", "Left Align"); + m_CenterAlignText = EditorGUIUtility.IconContent(@"GUISystem/align_horizontally_center", "Center Align"); + m_RightAlignText = EditorGUIUtility.IconContent(@"GUISystem/align_horizontally_right", "Right Align"); + m_LeftAlignTextActive = EditorGUIUtility.IconContent(@"GUISystem/align_horizontally_left_active", "Left Align"); + m_CenterAlignTextActive = EditorGUIUtility.IconContent(@"GUISystem/align_horizontally_center_active", "Center Align"); + m_RightAlignTextActive = EditorGUIUtility.IconContent(@"GUISystem/align_horizontally_right_active", "Right Align"); + + // Vertical Alignment Icons + m_TopAlignText = EditorGUIUtility.IconContent(@"GUISystem/align_vertically_top", "Top Align"); + m_MiddleAlignText = EditorGUIUtility.IconContent(@"GUISystem/align_vertically_center", "Middle Align"); + m_BottomAlignText = EditorGUIUtility.IconContent(@"GUISystem/align_vertically_bottom", "Bottom Align"); + m_TopAlignTextActive = EditorGUIUtility.IconContent(@"GUISystem/align_vertically_top_active", "Top Align"); + m_MiddleAlignTextActive = EditorGUIUtility.IconContent(@"GUISystem/align_vertically_center_active", "Middle Align"); + m_BottomAlignTextActive = EditorGUIUtility.IconContent(@"GUISystem/align_vertically_bottom_active", "Bottom Align"); + + FixAlignmentButtonStyles(alignmentButtonLeft, alignmentButtonMid, alignmentButtonRight); + } + + static void FixAlignmentButtonStyles(params GUIStyle[] styles) + { + foreach (GUIStyle style in styles) + { + style.padding.left = 2; + style.padding.right = 2; + } + } + } + + private enum VerticalTextAligment + { + Top, + Middle, + Bottom + } + + private enum HorizontalTextAligment + { + Left, + Center, + Right + } + + private const int kAlignmentButtonWidth = 20; + + static int s_TextAlignmentHash = "DoTextAligmentControl".GetHashCode(); + + private SerializedProperty m_SupportEncoding; + private SerializedProperty m_Font; + private SerializedProperty m_FontSize; + private SerializedProperty m_LineSpacing; + private SerializedProperty m_FontStyle; + private SerializedProperty m_ResizeTextForBestFit; + private SerializedProperty m_ResizeTextMinSize; + private SerializedProperty m_ResizeTextMaxSize; + private SerializedProperty m_HorizontalOverflow; + private SerializedProperty m_VerticalOverflow; + private SerializedProperty m_Alignment; + private SerializedProperty m_AlignByGeometry; + + private float m_FontFieldfHeight = 0f; + private float m_FontStyleHeight = 0f; + private float m_FontSizeHeight = 0f; + private float m_LineSpacingHeight = 0f; + private float m_EncodingHeight = 0f; + private float m_ResizeTextForBestFitHeight = 0f; + private float m_ResizeTextMinSizeHeight = 0f; + private float m_ResizeTextMaxSizeHeight = 0f; + private float m_HorizontalOverflowHeight = 0f; + private float m_VerticalOverflowHeight = 0f; + private float m_AlignByGeometryHeight = 0f; + + protected void Init(SerializedProperty property) + { + m_SupportEncoding = property.FindPropertyRelative("m_RichText"); + m_Font = property.FindPropertyRelative("m_Font"); + m_FontSize = property.FindPropertyRelative("m_FontSize"); + m_LineSpacing = property.FindPropertyRelative("m_LineSpacing"); + m_FontStyle = property.FindPropertyRelative("m_FontStyle"); + m_ResizeTextForBestFit = property.FindPropertyRelative("m_BestFit"); + m_ResizeTextMinSize = property.FindPropertyRelative("m_MinSize"); + m_ResizeTextMaxSize = property.FindPropertyRelative("m_MaxSize"); + m_HorizontalOverflow = property.FindPropertyRelative("m_HorizontalOverflow"); + m_VerticalOverflow = property.FindPropertyRelative("m_VerticalOverflow"); + m_Alignment = property.FindPropertyRelative("m_Alignment"); + m_AlignByGeometry = property.FindPropertyRelative("m_AlignByGeometry"); + } + + public override float GetPropertyHeight(SerializedProperty property, GUIContent label) + { + Init(property); + m_FontFieldfHeight = EditorGUI.GetPropertyHeight(m_Font); + m_FontStyleHeight = EditorGUI.GetPropertyHeight(m_FontStyle); + m_FontSizeHeight = EditorGUI.GetPropertyHeight(m_FontSize); + m_LineSpacingHeight = EditorGUI.GetPropertyHeight(m_LineSpacing); + m_EncodingHeight = EditorGUI.GetPropertyHeight(m_SupportEncoding); + m_ResizeTextForBestFitHeight = EditorGUI.GetPropertyHeight(m_ResizeTextForBestFit); + m_ResizeTextMinSizeHeight = EditorGUI.GetPropertyHeight(m_ResizeTextMinSize); + m_ResizeTextMaxSizeHeight = EditorGUI.GetPropertyHeight(m_ResizeTextMaxSize); + m_HorizontalOverflowHeight = EditorGUI.GetPropertyHeight(m_HorizontalOverflow); + m_VerticalOverflowHeight = EditorGUI.GetPropertyHeight(m_VerticalOverflow); + m_AlignByGeometryHeight = EditorGUI.GetPropertyHeight(m_AlignByGeometry); + + var height = m_FontFieldfHeight + + m_FontStyleHeight + + m_FontSizeHeight + + m_LineSpacingHeight + + m_EncodingHeight + + m_ResizeTextForBestFitHeight + + m_HorizontalOverflowHeight + + m_VerticalOverflowHeight + + EditorGUIUtility.singleLineHeight * 3 + + EditorGUIUtility.standardVerticalSpacing * 10 + + m_AlignByGeometryHeight; + + if (m_ResizeTextForBestFit.boolValue) + { + height += m_ResizeTextMinSizeHeight + + m_ResizeTextMaxSizeHeight + + EditorGUIUtility.standardVerticalSpacing * 2; + } + return height; + } + + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + Init(property); + + Rect rect = position; + rect.height = EditorGUIUtility.singleLineHeight; + + EditorGUI.LabelField(rect, "Character", EditorStyles.boldLabel); + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + ++EditorGUI.indentLevel; + { + Font font = m_Font.objectReferenceValue as Font; + rect.height = m_FontFieldfHeight; + EditorGUI.BeginChangeCheck(); + EditorGUI.PropertyField(rect, m_Font); + if (EditorGUI.EndChangeCheck()) + { + font = m_Font.objectReferenceValue as Font; + if (font != null && !font.dynamic) + m_FontSize.intValue = font.fontSize; + } + + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + rect.height = m_FontStyleHeight; + using (new EditorGUI.DisabledScope(!m_Font.hasMultipleDifferentValues && font != null && !font.dynamic)) + { + EditorGUI.PropertyField(rect, m_FontStyle); + } + + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + rect.height = m_FontSizeHeight; + EditorGUI.PropertyField(rect, m_FontSize); + + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + rect.height = m_LineSpacingHeight; + EditorGUI.PropertyField(rect, m_LineSpacing); + + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + rect.height = m_EncodingHeight; + EditorGUI.PropertyField(rect, m_SupportEncoding, Styles.m_EncodingContent); + } + --EditorGUI.indentLevel; + + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + rect.height = EditorGUIUtility.singleLineHeight; + EditorGUI.LabelField(rect, "Paragraph", EditorStyles.boldLabel); + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + ++EditorGUI.indentLevel; + { + rect.height = EditorGUIUtility.singleLineHeight; + DoTextAligmentControl(rect, m_Alignment); + + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + rect.height = m_HorizontalOverflowHeight; + EditorGUI.PropertyField(rect, m_AlignByGeometry); + + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + rect.height = m_HorizontalOverflowHeight; + EditorGUI.PropertyField(rect, m_HorizontalOverflow); + + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + rect.height = m_VerticalOverflowHeight; + EditorGUI.PropertyField(rect, m_VerticalOverflow); + + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + rect.height = m_ResizeTextMaxSizeHeight; + EditorGUI.PropertyField(rect, m_ResizeTextForBestFit); + + if (m_ResizeTextForBestFit.boolValue) + { + EditorGUILayout.EndFadeGroup(); + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + rect.height = m_ResizeTextMinSizeHeight; + EditorGUI.PropertyField(rect, m_ResizeTextMinSize); + + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + rect.height = m_ResizeTextMaxSizeHeight; + EditorGUI.PropertyField(rect, m_ResizeTextMaxSize); + } + } + --EditorGUI.indentLevel; + } + + private void DoTextAligmentControl(Rect position, SerializedProperty alignment) + { + GUIContent alingmentContent = new GUIContent("Alignment"); + + int id = EditorGUIUtility.GetControlID(s_TextAlignmentHash, FocusType.Keyboard, position); + + EditorGUIUtility.SetIconSize(new Vector2(15, 15)); + EditorGUI.BeginProperty(position, alingmentContent, alignment); + { + Rect controlArea = EditorGUI.PrefixLabel(position, id, alingmentContent); + + float width = kAlignmentButtonWidth * 3; + float spacing = Mathf.Clamp(controlArea.width - width * 2, 2, 10); + + Rect horizontalAligment = new Rect(controlArea.x, controlArea.y, width, controlArea.height); + Rect verticalAligment = new Rect(horizontalAligment.xMax + spacing, controlArea.y, width, controlArea.height); + + DoHorizontalAligmentControl(horizontalAligment, alignment); + DoVerticalAligmentControl(verticalAligment, alignment); + } + EditorGUI.EndProperty(); + EditorGUIUtility.SetIconSize(Vector2.zero); + } + + private static void DoHorizontalAligmentControl(Rect position, SerializedProperty alignment) + { + TextAnchor ta = (TextAnchor)alignment.intValue; + HorizontalTextAligment horizontalAlignment = GetHorizontalAlignment(ta); + + bool leftAlign = (horizontalAlignment == HorizontalTextAligment.Left); + bool centerAlign = (horizontalAlignment == HorizontalTextAligment.Center); + bool rightAlign = (horizontalAlignment == HorizontalTextAligment.Right); + + if (alignment.hasMultipleDifferentValues) + { + foreach (var obj in alignment.serializedObject.targetObjects) + { + Text text = obj as Text; + horizontalAlignment = GetHorizontalAlignment(text.alignment); + leftAlign = leftAlign || (horizontalAlignment == HorizontalTextAligment.Left); + centerAlign = centerAlign || (horizontalAlignment == HorizontalTextAligment.Center); + rightAlign = rightAlign || (horizontalAlignment == HorizontalTextAligment.Right); + } + } + + position.width = kAlignmentButtonWidth; + + EditorGUI.BeginChangeCheck(); + EditorToggle(position, leftAlign, leftAlign ? Styles.m_LeftAlignTextActive : Styles.m_LeftAlignText, Styles.alignmentButtonLeft); + if (EditorGUI.EndChangeCheck()) + { + SetHorizontalAlignment(alignment, HorizontalTextAligment.Left); + } + + position.x += position.width; + EditorGUI.BeginChangeCheck(); + EditorToggle(position, centerAlign, centerAlign ? Styles.m_CenterAlignTextActive : Styles.m_CenterAlignText, Styles.alignmentButtonMid); + if (EditorGUI.EndChangeCheck()) + { + SetHorizontalAlignment(alignment, HorizontalTextAligment.Center); + } + + position.x += position.width; + EditorGUI.BeginChangeCheck(); + EditorToggle(position, rightAlign, rightAlign ? Styles.m_RightAlignTextActive : Styles.m_RightAlignText, Styles.alignmentButtonRight); + if (EditorGUI.EndChangeCheck()) + { + SetHorizontalAlignment(alignment, HorizontalTextAligment.Right); + } + } + + private static void DoVerticalAligmentControl(Rect position, SerializedProperty alignment) + { + TextAnchor ta = (TextAnchor)alignment.intValue; + VerticalTextAligment verticalTextAligment = GetVerticalAlignment(ta); + + bool topAlign = (verticalTextAligment == VerticalTextAligment.Top); + bool middleAlign = (verticalTextAligment == VerticalTextAligment.Middle); + bool bottomAlign = (verticalTextAligment == VerticalTextAligment.Bottom); + + if (alignment.hasMultipleDifferentValues) + { + foreach (var obj in alignment.serializedObject.targetObjects) + { + Text text = obj as Text; + TextAnchor textAlignment = text.alignment; + verticalTextAligment = GetVerticalAlignment(textAlignment); + topAlign = topAlign || (verticalTextAligment == VerticalTextAligment.Top); + middleAlign = middleAlign || (verticalTextAligment == VerticalTextAligment.Middle); + bottomAlign = bottomAlign || (verticalTextAligment == VerticalTextAligment.Bottom); + } + } + + + position.width = kAlignmentButtonWidth; + + // position.x += position.width; + EditorGUI.BeginChangeCheck(); + EditorToggle(position, topAlign, topAlign ? Styles.m_TopAlignTextActive : Styles.m_TopAlignText, Styles.alignmentButtonLeft); + if (EditorGUI.EndChangeCheck()) + { + SetVerticalAlignment(alignment, VerticalTextAligment.Top); + } + + position.x += position.width; + EditorGUI.BeginChangeCheck(); + EditorToggle(position, middleAlign, middleAlign ? Styles.m_MiddleAlignTextActive : Styles.m_MiddleAlignText, Styles.alignmentButtonMid); + if (EditorGUI.EndChangeCheck()) + { + SetVerticalAlignment(alignment, VerticalTextAligment.Middle); + } + + position.x += position.width; + EditorGUI.BeginChangeCheck(); + EditorToggle(position, bottomAlign, bottomAlign ? Styles.m_BottomAlignTextActive : Styles.m_BottomAlignText, Styles.alignmentButtonRight); + if (EditorGUI.EndChangeCheck()) + { + SetVerticalAlignment(alignment, VerticalTextAligment.Bottom); + } + } + + private static bool EditorToggle(Rect position, bool value, GUIContent content, GUIStyle style) + { + int hashCode = "AlignToggle".GetHashCode(); + int id = EditorGUIUtility.GetControlID(hashCode, FocusType.Keyboard, position); + Event evt = Event.current; + + // Toggle selected toggle on space or return key + if (EditorGUIUtility.keyboardControl == id && evt.type == EventType.KeyDown && (evt.keyCode == KeyCode.Space || evt.keyCode == KeyCode.Return || evt.keyCode == KeyCode.KeypadEnter)) + { + value = !value; + evt.Use(); + GUI.changed = true; + } + + if (evt.type == EventType.KeyDown && Event.current.button == 0 && position.Contains(Event.current.mousePosition)) + { + GUIUtility.keyboardControl = id; + EditorGUIUtility.editingTextField = false; + HandleUtility.Repaint(); + } + + bool returnValue = GUI.Toggle(position, id, value, content, style); + + return returnValue; + } + + private static HorizontalTextAligment GetHorizontalAlignment(TextAnchor ta) + { + switch (ta) + { + case TextAnchor.MiddleCenter: + case TextAnchor.UpperCenter: + case TextAnchor.LowerCenter: + return HorizontalTextAligment.Center; + + case TextAnchor.UpperRight: + case TextAnchor.MiddleRight: + case TextAnchor.LowerRight: + return HorizontalTextAligment.Right; + + case TextAnchor.UpperLeft: + case TextAnchor.MiddleLeft: + case TextAnchor.LowerLeft: + return HorizontalTextAligment.Left; + } + + return HorizontalTextAligment.Left; + } + + private static VerticalTextAligment GetVerticalAlignment(TextAnchor ta) + { + switch (ta) + { + case TextAnchor.UpperLeft: + case TextAnchor.UpperCenter: + case TextAnchor.UpperRight: + return VerticalTextAligment.Top; + + case TextAnchor.MiddleLeft: + case TextAnchor.MiddleCenter: + case TextAnchor.MiddleRight: + return VerticalTextAligment.Middle; + + case TextAnchor.LowerLeft: + case TextAnchor.LowerCenter: + case TextAnchor.LowerRight: + return VerticalTextAligment.Bottom; + } + + return VerticalTextAligment.Top; + } + + // We can't go through serialized properties here since we're showing two controls for a single SerializzedProperty. + private static void SetHorizontalAlignment(SerializedProperty alignment, HorizontalTextAligment horizontalAlignment) + { + foreach (var obj in alignment.serializedObject.targetObjects) + { + Text text = obj as Text; + VerticalTextAligment currentVerticalAligment = GetVerticalAlignment(text.alignment); + Undo.RecordObject(text, "Horizontal Alignment"); + text.alignment = GetAnchor(currentVerticalAligment, horizontalAlignment); + EditorUtility.SetDirty(obj); + } + } + + private static void SetVerticalAlignment(SerializedProperty alignment, VerticalTextAligment verticalAlignment) + { + foreach (var obj in alignment.serializedObject.targetObjects) + { + Text text = obj as Text; + HorizontalTextAligment currentHorizontalAligment = GetHorizontalAlignment(text.alignment); + Undo.RecordObject(text, "Vertical Alignment"); + text.alignment = GetAnchor(verticalAlignment, currentHorizontalAligment); + EditorUtility.SetDirty(obj); + } + } + + private static TextAnchor GetAnchor(VerticalTextAligment verticalTextAligment, HorizontalTextAligment horizontalTextAligment) + { + TextAnchor ac = TextAnchor.UpperLeft; + + switch (horizontalTextAligment) + { + case HorizontalTextAligment.Left: + switch (verticalTextAligment) + { + case VerticalTextAligment.Bottom: + ac = TextAnchor.LowerLeft; + break; + case VerticalTextAligment.Middle: + ac = TextAnchor.MiddleLeft; + break; + default: + ac = TextAnchor.UpperLeft; + break; + } + break; + case HorizontalTextAligment.Center: + switch (verticalTextAligment) + { + case VerticalTextAligment.Bottom: + ac = TextAnchor.LowerCenter; + break; + case VerticalTextAligment.Middle: + ac = TextAnchor.MiddleCenter; + break; + default: + ac = TextAnchor.UpperCenter; + break; + } + break; + default: + switch (verticalTextAligment) + { + case VerticalTextAligment.Bottom: + ac = TextAnchor.LowerRight; + break; + case VerticalTextAligment.Middle: + ac = TextAnchor.MiddleRight; + break; + default: + ac = TextAnchor.UpperRight; + break; + } + break; + } + return ac; + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/FontDataDrawer.cs.meta b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/FontDataDrawer.cs.meta new file mode 100644 index 0000000..01a9f7b --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/FontDataDrawer.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 9a502f8fd08923f4a804fcbbc63bab90 +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/NavigationDrawer.cs b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/NavigationDrawer.cs new file mode 100644 index 0000000..2cfc4d3 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/NavigationDrawer.cs @@ -0,0 +1,83 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomPropertyDrawer(typeof(Navigation), true)] + public class NavigationDrawer : PropertyDrawer + { + private class Styles + { + readonly public GUIContent navigationContent; + + public Styles() + { + navigationContent = new GUIContent("Navigation"); + } + } + + private static Styles s_Styles = null; + + public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label) + { + if (s_Styles == null) + s_Styles = new Styles(); + + Rect drawRect = pos; + drawRect.height = EditorGUIUtility.singleLineHeight; + + SerializedProperty navigation = prop.FindPropertyRelative("m_Mode"); + Navigation.Mode navMode = GetNavigationMode(navigation); + + EditorGUI.PropertyField(drawRect, navigation, s_Styles.navigationContent); + + ++EditorGUI.indentLevel; + + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + + switch (navMode) + { + case Navigation.Mode.Explicit: + { + SerializedProperty selectOnUp = prop.FindPropertyRelative("m_SelectOnUp"); + SerializedProperty selectOnDown = prop.FindPropertyRelative("m_SelectOnDown"); + SerializedProperty selectOnLeft = prop.FindPropertyRelative("m_SelectOnLeft"); + SerializedProperty selectOnRight = prop.FindPropertyRelative("m_SelectOnRight"); + + EditorGUI.PropertyField(drawRect, selectOnUp); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, selectOnDown); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, selectOnLeft); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, selectOnRight); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + } + break; + } + + --EditorGUI.indentLevel; + } + + static Navigation.Mode GetNavigationMode(SerializedProperty navigation) + { + return (Navigation.Mode)navigation.enumValueIndex; + } + + public override float GetPropertyHeight(SerializedProperty prop, GUIContent label) + { + SerializedProperty navigation = prop.FindPropertyRelative("m_Mode"); + if (navigation == null) + return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + + Navigation.Mode navMode = GetNavigationMode(navigation); + + switch (navMode) + { + case Navigation.Mode.None: return EditorGUIUtility.singleLineHeight; + case Navigation.Mode.Explicit: return 5 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing; + default: return EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing; + } + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/NavigationDrawer.cs.meta b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/NavigationDrawer.cs.meta new file mode 100644 index 0000000..6eb8468 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/NavigationDrawer.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 9fc1ecf033776204b9a224661a28dcfd +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/SpriteStateDrawer.cs b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/SpriteStateDrawer.cs new file mode 100644 index 0000000..510db1a --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/SpriteStateDrawer.cs @@ -0,0 +1,30 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomPropertyDrawer(typeof(SpriteState), true)] + public class SpriteStateDrawer : PropertyDrawer + { + public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label) + { + Rect drawRect = rect; + drawRect.height = EditorGUIUtility.singleLineHeight; + SerializedProperty highlightedSprite = prop.FindPropertyRelative("m_HighlightedSprite"); + SerializedProperty pressedSprite = prop.FindPropertyRelative("m_PressedSprite"); + SerializedProperty disabledSprite = prop.FindPropertyRelative("m_DisabledSprite"); + + EditorGUI.PropertyField(drawRect, highlightedSprite); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, pressedSprite); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, disabledSprite); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + } + + public override float GetPropertyHeight(SerializedProperty prop, GUIContent label) + { + return 3 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing; + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/SpriteStateDrawer.cs.meta b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/SpriteStateDrawer.cs.meta new file mode 100644 index 0000000..cbcad61 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/SpriteStateDrawer.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: cc8f8e0433b0dff4289da30bc91c831d +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/RawImageEditor.cs b/Assets/uGUI-2017.1/Editor/UI/RawImageEditor.cs new file mode 100644 index 0000000..36e43b1 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/RawImageEditor.cs @@ -0,0 +1,107 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + /// + /// Editor class used to edit UI Images. + /// + [CustomEditor(typeof(RawImage), true)] + [CanEditMultipleObjects] + public class RawImageEditor : GraphicEditor + { + SerializedProperty m_Texture; + SerializedProperty m_UVRect; + GUIContent m_UVRectContent; + + protected override void OnEnable() + { + base.OnEnable(); + + // Note we have precedence for calling rectangle for just rect, even in the Inspector. + // For example in the Camera component's Viewport Rect. + // Hence sticking with Rect here to be consistent with corresponding property in the API. + m_UVRectContent = new GUIContent("UV Rect"); + + m_Texture = serializedObject.FindProperty("m_Texture"); + m_UVRect = serializedObject.FindProperty("m_UVRect"); + + SetShowNativeSize(true); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + EditorGUILayout.PropertyField(m_Texture); + AppearanceControlsGUI(); + RaycastControlsGUI(); + EditorGUILayout.PropertyField(m_UVRect, m_UVRectContent); + SetShowNativeSize(false); + NativeSizeButtonGUI(); + + serializedObject.ApplyModifiedProperties(); + } + + void SetShowNativeSize(bool instant) + { + base.SetShowNativeSize(m_Texture.objectReferenceValue != null, instant); + } + + private static Rect Outer(RawImage rawImage) + { + Rect outer = rawImage.uvRect; + outer.xMin *= rawImage.rectTransform.rect.width; + outer.xMax *= rawImage.rectTransform.rect.width; + outer.yMin *= rawImage.rectTransform.rect.height; + outer.yMax *= rawImage.rectTransform.rect.height; + return outer; + } + + /// + /// Allow the texture to be previewed. + /// + + public override bool HasPreviewGUI() + { + RawImage rawImage = target as RawImage; + if (rawImage == null) + return false; + + var outer = Outer(rawImage); + return outer.width > 0 && outer.height > 0; + } + + /// + /// Draw the Image preview. + /// + + public override void OnPreviewGUI(Rect rect, GUIStyle background) + { + RawImage rawImage = target as RawImage; + Texture tex = rawImage.mainTexture; + + if (tex == null) + return; + + var outer = Outer(rawImage); + SpriteDrawUtility.DrawSprite(tex, rect, outer, rawImage.uvRect, rawImage.canvasRenderer.GetColor()); + } + + /// + /// Info String drawn at the bottom of the Preview + /// + + public override string GetInfoString() + { + RawImage rawImage = target as RawImage; + + // Image size Text + string text = string.Format("RawImage Size: {0}x{1}", + Mathf.RoundToInt(Mathf.Abs(rawImage.rectTransform.rect.width)), + Mathf.RoundToInt(Mathf.Abs(rawImage.rectTransform.rect.height))); + + return text; + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/RawImageEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/RawImageEditor.cs.meta new file mode 100644 index 0000000..c5b427a --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/RawImageEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 735e178f724133c42b4eeb469dd13867 +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/RectMask2DEditor.cs b/Assets/uGUI-2017.1/Editor/UI/RectMask2DEditor.cs new file mode 100644 index 0000000..cad5773 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/RectMask2DEditor.cs @@ -0,0 +1,13 @@ +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(RectMask2D), true)] + [CanEditMultipleObjects] + public class RectMask2DEditor : Editor + { + public override void OnInspectorGUI() + { + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/RectMask2DEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/RectMask2DEditor.cs.meta new file mode 100644 index 0000000..02621a3 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/RectMask2DEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: a2e0aadc108e8f342a529c3ff8e70470 +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/ScrollRectEditor.cs b/Assets/uGUI-2017.1/Editor/UI/ScrollRectEditor.cs new file mode 100644 index 0000000..56e7d64 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/ScrollRectEditor.cs @@ -0,0 +1,172 @@ +using UnityEngine; +using UnityEngine.UI; +using UnityEditor.AnimatedValues; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(ScrollRect), true)] + [CanEditMultipleObjects] + public class ScrollRectEditor : Editor + { + SerializedProperty m_Content; + SerializedProperty m_Horizontal; + SerializedProperty m_Vertical; + SerializedProperty m_MovementType; + SerializedProperty m_Elasticity; + SerializedProperty m_Inertia; + SerializedProperty m_DecelerationRate; + SerializedProperty m_ScrollSensitivity; + SerializedProperty m_Viewport; + SerializedProperty m_HorizontalScrollbar; + SerializedProperty m_VerticalScrollbar; + SerializedProperty m_HorizontalScrollbarVisibility; + SerializedProperty m_VerticalScrollbarVisibility; + SerializedProperty m_HorizontalScrollbarSpacing; + SerializedProperty m_VerticalScrollbarSpacing; + SerializedProperty m_OnValueChanged; + AnimBool m_ShowElasticity; + AnimBool m_ShowDecelerationRate; + bool m_ViewportIsNotChild, m_HScrollbarIsNotChild, m_VScrollbarIsNotChild; + static string s_HError = "For this visibility mode, the Viewport property and the Horizontal Scrollbar property both needs to be set to a Rect Transform that is a child to the Scroll Rect."; + static string s_VError = "For this visibility mode, the Viewport property and the Vertical Scrollbar property both needs to be set to a Rect Transform that is a child to the Scroll Rect."; + + protected virtual void OnEnable() + { + m_Content = serializedObject.FindProperty("m_Content"); + m_Horizontal = serializedObject.FindProperty("m_Horizontal"); + m_Vertical = serializedObject.FindProperty("m_Vertical"); + m_MovementType = serializedObject.FindProperty("m_MovementType"); + m_Elasticity = serializedObject.FindProperty("m_Elasticity"); + m_Inertia = serializedObject.FindProperty("m_Inertia"); + m_DecelerationRate = serializedObject.FindProperty("m_DecelerationRate"); + m_ScrollSensitivity = serializedObject.FindProperty("m_ScrollSensitivity"); + m_Viewport = serializedObject.FindProperty("m_Viewport"); + m_HorizontalScrollbar = serializedObject.FindProperty("m_HorizontalScrollbar"); + m_VerticalScrollbar = serializedObject.FindProperty("m_VerticalScrollbar"); + m_HorizontalScrollbarVisibility = serializedObject.FindProperty("m_HorizontalScrollbarVisibility"); + m_VerticalScrollbarVisibility = serializedObject.FindProperty("m_VerticalScrollbarVisibility"); + m_HorizontalScrollbarSpacing = serializedObject.FindProperty("m_HorizontalScrollbarSpacing"); + m_VerticalScrollbarSpacing = serializedObject.FindProperty("m_VerticalScrollbarSpacing"); + m_OnValueChanged = serializedObject.FindProperty("m_OnValueChanged"); + + m_ShowElasticity = new AnimBool(Repaint); + m_ShowDecelerationRate = new AnimBool(Repaint); + SetAnimBools(true); + } + + protected virtual void OnDisable() + { + m_ShowElasticity.valueChanged.RemoveListener(Repaint); + m_ShowDecelerationRate.valueChanged.RemoveListener(Repaint); + } + + void SetAnimBools(bool instant) + { + SetAnimBool(m_ShowElasticity, !m_MovementType.hasMultipleDifferentValues && m_MovementType.enumValueIndex == (int)ScrollRect.MovementType.Elastic, instant); + SetAnimBool(m_ShowDecelerationRate, !m_Inertia.hasMultipleDifferentValues && m_Inertia.boolValue == true, instant); + } + + void SetAnimBool(AnimBool a, bool value, bool instant) + { + if (instant) + a.value = value; + else + a.target = value; + } + + void CalculateCachedValues() + { + m_ViewportIsNotChild = false; + m_HScrollbarIsNotChild = false; + m_VScrollbarIsNotChild = false; + if (targets.Length == 1) + { + Transform transform = ((ScrollRect)target).transform; + if (m_Viewport.objectReferenceValue == null || ((RectTransform)m_Viewport.objectReferenceValue).transform.parent != transform) + m_ViewportIsNotChild = true; + if (m_HorizontalScrollbar.objectReferenceValue == null || ((Scrollbar)m_HorizontalScrollbar.objectReferenceValue).transform.parent != transform) + m_HScrollbarIsNotChild = true; + if (m_VerticalScrollbar.objectReferenceValue == null || ((Scrollbar)m_VerticalScrollbar.objectReferenceValue).transform.parent != transform) + m_VScrollbarIsNotChild = true; + } + } + + public override void OnInspectorGUI() + { + SetAnimBools(false); + + serializedObject.Update(); + // Once we have a reliable way to know if the object changed, only re-cache in that case. + CalculateCachedValues(); + + EditorGUILayout.PropertyField(m_Content); + + EditorGUILayout.PropertyField(m_Horizontal); + EditorGUILayout.PropertyField(m_Vertical); + + EditorGUILayout.PropertyField(m_MovementType); + if (EditorGUILayout.BeginFadeGroup(m_ShowElasticity.faded)) + { + EditorGUI.indentLevel++; + EditorGUILayout.PropertyField(m_Elasticity); + EditorGUI.indentLevel--; + } + EditorGUILayout.EndFadeGroup(); + + EditorGUILayout.PropertyField(m_Inertia); + if (EditorGUILayout.BeginFadeGroup(m_ShowDecelerationRate.faded)) + { + EditorGUI.indentLevel++; + EditorGUILayout.PropertyField(m_DecelerationRate); + EditorGUI.indentLevel--; + } + EditorGUILayout.EndFadeGroup(); + + EditorGUILayout.PropertyField(m_ScrollSensitivity); + + EditorGUILayout.Space(); + + EditorGUILayout.PropertyField(m_Viewport); + + EditorGUILayout.PropertyField(m_HorizontalScrollbar); + if (m_HorizontalScrollbar.objectReferenceValue && !m_HorizontalScrollbar.hasMultipleDifferentValues) + { + EditorGUI.indentLevel++; + EditorGUILayout.PropertyField(m_HorizontalScrollbarVisibility, new GUIContent("Visibility")); + + if ((ScrollRect.ScrollbarVisibility)m_HorizontalScrollbarVisibility.enumValueIndex == ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport + && !m_HorizontalScrollbarVisibility.hasMultipleDifferentValues) + { + if (m_ViewportIsNotChild || m_HScrollbarIsNotChild) + EditorGUILayout.HelpBox(s_HError, MessageType.Error); + EditorGUILayout.PropertyField(m_HorizontalScrollbarSpacing, new GUIContent("Spacing")); + } + + EditorGUI.indentLevel--; + } + + EditorGUILayout.PropertyField(m_VerticalScrollbar); + if (m_VerticalScrollbar.objectReferenceValue && !m_VerticalScrollbar.hasMultipleDifferentValues) + { + EditorGUI.indentLevel++; + EditorGUILayout.PropertyField(m_VerticalScrollbarVisibility, new GUIContent("Visibility")); + + if ((ScrollRect.ScrollbarVisibility)m_VerticalScrollbarVisibility.enumValueIndex == ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport + && !m_VerticalScrollbarVisibility.hasMultipleDifferentValues) + { + if (m_ViewportIsNotChild || m_VScrollbarIsNotChild) + EditorGUILayout.HelpBox(s_VError, MessageType.Error); + EditorGUILayout.PropertyField(m_VerticalScrollbarSpacing, new GUIContent("Spacing")); + } + + EditorGUI.indentLevel--; + } + + EditorGUILayout.Space(); + + EditorGUILayout.PropertyField(m_OnValueChanged); + + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/ScrollRectEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/ScrollRectEditor.cs.meta new file mode 100644 index 0000000..4311b0b --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/ScrollRectEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ff377b0e7561593448ad1c54668efe83 +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/ScrollbarEditor.cs b/Assets/uGUI-2017.1/Editor/UI/ScrollbarEditor.cs new file mode 100644 index 0000000..73b97d6 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/ScrollbarEditor.cs @@ -0,0 +1,102 @@ +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(Scrollbar), true)] + [CanEditMultipleObjects] + public class ScrollbarEditor : SelectableEditor + { + SerializedProperty m_HandleRect; + SerializedProperty m_Direction; + SerializedProperty m_Value; + SerializedProperty m_Size; + SerializedProperty m_NumberOfSteps; + SerializedProperty m_OnValueChanged; + + protected override void OnEnable() + { + base.OnEnable(); + + m_HandleRect = serializedObject.FindProperty("m_HandleRect"); + m_Direction = serializedObject.FindProperty("m_Direction"); + m_Value = serializedObject.FindProperty("m_Value"); + m_Size = serializedObject.FindProperty("m_Size"); + m_NumberOfSteps = serializedObject.FindProperty("m_NumberOfSteps"); + m_OnValueChanged = serializedObject.FindProperty("m_OnValueChanged"); + } + + public override void OnInspectorGUI() + { + base.OnInspectorGUI(); + EditorGUILayout.Space(); + + serializedObject.Update(); + + // EditorGUILayout.PropertyField(m_HandleRect); + EditorGUI.BeginChangeCheck(); + RectTransform newRectTransform = EditorGUILayout.ObjectField("Handle Rect", m_HandleRect.objectReferenceValue, typeof(RectTransform), true) as RectTransform; + if (EditorGUI.EndChangeCheck()) + { + // Handle Rect will modify its GameObject RectTransform drivenBy, so we need to Record the old and new RectTransform. + List modifiedObjects = new List(); + modifiedObjects.Add(newRectTransform); + foreach (var target in m_HandleRect.serializedObject.targetObjects) + { + MonoBehaviour mb = target as MonoBehaviour; + if (mb == null) + continue; + + modifiedObjects.Add(mb); + modifiedObjects.Add(mb.GetComponent()); + } + Undo.RecordObjects(modifiedObjects.ToArray(), "Change Handle Rect"); + m_HandleRect.objectReferenceValue = newRectTransform; + } + + if (m_HandleRect.objectReferenceValue != null) + { + EditorGUI.BeginChangeCheck(); + EditorGUILayout.PropertyField(m_Direction); + if (EditorGUI.EndChangeCheck()) + { + Scrollbar.Direction direction = (Scrollbar.Direction)m_Direction.enumValueIndex; + foreach (var obj in serializedObject.targetObjects) + { + Scrollbar scrollbar = obj as Scrollbar; + scrollbar.SetDirection(direction, true); + } + } + + EditorGUILayout.PropertyField(m_Value); + EditorGUILayout.PropertyField(m_Size); + EditorGUILayout.PropertyField(m_NumberOfSteps); + + bool warning = false; + foreach (var obj in serializedObject.targetObjects) + { + Scrollbar scrollbar = obj as Scrollbar; + Scrollbar.Direction dir = scrollbar.direction; + if (dir == Scrollbar.Direction.LeftToRight || dir == Scrollbar.Direction.RightToLeft) + warning = (scrollbar.navigation.mode != Navigation.Mode.Automatic && (scrollbar.FindSelectableOnLeft() != null || scrollbar.FindSelectableOnRight() != null)); + else + warning = (scrollbar.navigation.mode != Navigation.Mode.Automatic && (scrollbar.FindSelectableOnDown() != null || scrollbar.FindSelectableOnUp() != null)); + } + + if (warning) + EditorGUILayout.HelpBox("The selected scrollbar direction conflicts with navigation. Not all navigation options may work.", MessageType.Warning); + + EditorGUILayout.Space(); + // Draw the event notification options + EditorGUILayout.PropertyField(m_OnValueChanged); + } + else + { + EditorGUILayout.HelpBox("Specify a RectTransform for the scrollbar handle. It must have a parent RectTransform that the handle can slide within.", MessageType.Info); + } + + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/ScrollbarEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/ScrollbarEditor.cs.meta new file mode 100644 index 0000000..80bbf88 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/ScrollbarEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 607de83ab7663e74dac5e5d063fb2954 +timeCreated: 1602119378 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/SelectableEditor.cs b/Assets/uGUI-2017.1/Editor/UI/SelectableEditor.cs new file mode 100644 index 0000000..d3329cc --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/SelectableEditor.cs @@ -0,0 +1,370 @@ +using System.Collections.Generic; +using System.Text; +using System.Linq; +using UnityEngine; +using UnityEngine.UI; +using UnityEditor.AnimatedValues; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(Selectable), true)] + public class SelectableEditor : Editor + { + SerializedProperty m_Script; + SerializedProperty m_InteractableProperty; + SerializedProperty m_TargetGraphicProperty; + SerializedProperty m_TransitionProperty; + SerializedProperty m_ColorBlockProperty; + SerializedProperty m_SpriteStateProperty; + SerializedProperty m_AnimTriggerProperty; + SerializedProperty m_NavigationProperty; + + GUIContent m_VisualizeNavigation = new GUIContent("Visualize", "Show navigation flows between selectable UI elements."); + + AnimBool m_ShowColorTint = new AnimBool(); + AnimBool m_ShowSpriteTrasition = new AnimBool(); + AnimBool m_ShowAnimTransition = new AnimBool(); + + private static List s_Editors = new List(); + private static bool s_ShowNavigation = false; + private static string s_ShowNavigationKey = "SelectableEditor.ShowNavigation"; + + // Whenever adding new SerializedProperties to the Selectable and SelectableEditor + // Also update this guy in OnEnable. This makes the inherited classes from Selectable not require a CustomEditor. + private string[] m_PropertyPathToExcludeForChildClasses; + + protected virtual void OnEnable() + { + m_Script = serializedObject.FindProperty("m_Script"); + m_InteractableProperty = serializedObject.FindProperty("m_Interactable"); + m_TargetGraphicProperty = serializedObject.FindProperty("m_TargetGraphic"); + m_TransitionProperty = serializedObject.FindProperty("m_Transition"); + m_ColorBlockProperty = serializedObject.FindProperty("m_Colors"); + m_SpriteStateProperty = serializedObject.FindProperty("m_SpriteState"); + m_AnimTriggerProperty = serializedObject.FindProperty("m_AnimationTriggers"); + m_NavigationProperty = serializedObject.FindProperty("m_Navigation"); + + m_PropertyPathToExcludeForChildClasses = new[] + { + m_Script.propertyPath, + m_NavigationProperty.propertyPath, + m_TransitionProperty.propertyPath, + m_ColorBlockProperty.propertyPath, + m_SpriteStateProperty.propertyPath, + m_AnimTriggerProperty.propertyPath, + m_InteractableProperty.propertyPath, + m_TargetGraphicProperty.propertyPath, + }; + + var trans = GetTransition(m_TransitionProperty); + m_ShowColorTint.value = (trans == Selectable.Transition.ColorTint); + m_ShowSpriteTrasition.value = (trans == Selectable.Transition.SpriteSwap); + m_ShowAnimTransition.value = (trans == Selectable.Transition.Animation); + + m_ShowColorTint.valueChanged.AddListener(Repaint); + m_ShowSpriteTrasition.valueChanged.AddListener(Repaint); + + s_Editors.Add(this); + RegisterStaticOnSceneGUI(); + + s_ShowNavigation = EditorPrefs.GetBool(s_ShowNavigationKey); + } + + protected virtual void OnDisable() + { + m_ShowColorTint.valueChanged.RemoveListener(Repaint); + m_ShowSpriteTrasition.valueChanged.RemoveListener(Repaint); + + s_Editors.Remove(this); + RegisterStaticOnSceneGUI(); + } + + private void RegisterStaticOnSceneGUI() + { + SceneView.onSceneGUIDelegate -= StaticOnSceneGUI; + if (s_Editors.Count > 0) + SceneView.onSceneGUIDelegate += StaticOnSceneGUI; + } + + static Selectable.Transition GetTransition(SerializedProperty transition) + { + return (Selectable.Transition)transition.enumValueIndex; + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + EditorGUILayout.PropertyField(m_InteractableProperty); + + var trans = GetTransition(m_TransitionProperty); + + var graphic = m_TargetGraphicProperty.objectReferenceValue as Graphic; + if (graphic == null) + graphic = (target as Selectable).GetComponent(); + + var animator = (target as Selectable).GetComponent(); + m_ShowColorTint.target = (!m_TransitionProperty.hasMultipleDifferentValues && trans == Button.Transition.ColorTint); + m_ShowSpriteTrasition.target = (!m_TransitionProperty.hasMultipleDifferentValues && trans == Button.Transition.SpriteSwap); + m_ShowAnimTransition.target = (!m_TransitionProperty.hasMultipleDifferentValues && trans == Button.Transition.Animation); + + EditorGUILayout.PropertyField(m_TransitionProperty); + + ++EditorGUI.indentLevel; + { + if (trans == Selectable.Transition.ColorTint || trans == Selectable.Transition.SpriteSwap) + { + EditorGUILayout.PropertyField(m_TargetGraphicProperty); + } + + switch (trans) + { + case Selectable.Transition.ColorTint: + if (graphic == null) + EditorGUILayout.HelpBox("You must have a Graphic target in order to use a color transition.", MessageType.Warning); + break; + + case Selectable.Transition.SpriteSwap: + if (graphic as Image == null) + EditorGUILayout.HelpBox("You must have a Image target in order to use a sprite swap transition.", MessageType.Warning); + break; + } + + if (EditorGUILayout.BeginFadeGroup(m_ShowColorTint.faded)) + { + EditorGUILayout.PropertyField(m_ColorBlockProperty); + } + EditorGUILayout.EndFadeGroup(); + + if (EditorGUILayout.BeginFadeGroup(m_ShowSpriteTrasition.faded)) + { + EditorGUILayout.PropertyField(m_SpriteStateProperty); + } + EditorGUILayout.EndFadeGroup(); + + if (EditorGUILayout.BeginFadeGroup(m_ShowAnimTransition.faded)) + { + EditorGUILayout.PropertyField(m_AnimTriggerProperty); + + if (animator == null || animator.runtimeAnimatorController == null) + { + Rect buttonRect = EditorGUILayout.GetControlRect(); + buttonRect.xMin += EditorGUIUtility.labelWidth; + if (GUI.Button(buttonRect, "Auto Generate Animation", EditorStyles.miniButton)) + { + var controller = GenerateSelectableAnimatorContoller((target as Selectable).animationTriggers, target as Selectable); + if (controller != null) + { + if (animator == null) + animator = (target as Selectable).gameObject.AddComponent(); + + Animations.AnimatorController.SetAnimatorController(animator, controller); + } + } + } + } + EditorGUILayout.EndFadeGroup(); + } + --EditorGUI.indentLevel; + + EditorGUILayout.Space(); + + EditorGUILayout.PropertyField(m_NavigationProperty); + + EditorGUI.BeginChangeCheck(); + Rect toggleRect = EditorGUILayout.GetControlRect(); + toggleRect.xMin += EditorGUIUtility.labelWidth; + s_ShowNavigation = GUI.Toggle(toggleRect, s_ShowNavigation, m_VisualizeNavigation, EditorStyles.miniButton); + if (EditorGUI.EndChangeCheck()) + { + EditorPrefs.SetBool(s_ShowNavigationKey, s_ShowNavigation); + SceneView.RepaintAll(); + } + + // We do this here to avoid requiring the user to also write a Editor for their Selectable-derived classes. + // This way if we are on a derived class we dont draw anything else, otherwise draw the remaining properties. + ChildClassPropertiesGUI(); + + serializedObject.ApplyModifiedProperties(); + } + + // Draw the extra SerializedProperties of the child class. + // We need to make sure that m_PropertyPathToExcludeForChildClasses has all the Selectable properties and in the correct order. + // TODO: find a nicer way of doing this. (creating a InheritedEditor class that automagically does this) + private void ChildClassPropertiesGUI() + { + if (IsDerivedSelectableEditor()) + return; + + DrawPropertiesExcluding(serializedObject, m_PropertyPathToExcludeForChildClasses); + } + + private bool IsDerivedSelectableEditor() + { + return GetType() != typeof(SelectableEditor); + } + + private static Animations.AnimatorController GenerateSelectableAnimatorContoller(AnimationTriggers animationTriggers, Selectable target) + { + if (target == null) + return null; + + // Where should we create the controller? + var path = GetSaveControllerPath(target); + if (string.IsNullOrEmpty(path)) + return null; + + // figure out clip names + var normalName = string.IsNullOrEmpty(animationTriggers.normalTrigger) ? "Normal" : animationTriggers.normalTrigger; + var highlightedName = string.IsNullOrEmpty(animationTriggers.highlightedTrigger) ? "Highlighted" : animationTriggers.highlightedTrigger; + var pressedName = string.IsNullOrEmpty(animationTriggers.pressedTrigger) ? "Pressed" : animationTriggers.pressedTrigger; + var disabledName = string.IsNullOrEmpty(animationTriggers.disabledTrigger) ? "Disabled" : animationTriggers.disabledTrigger; + + // Create controller and hook up transitions. + var controller = Animations.AnimatorController.CreateAnimatorControllerAtPath(path); + GenerateTriggerableTransition(normalName, controller); + GenerateTriggerableTransition(highlightedName, controller); + GenerateTriggerableTransition(pressedName, controller); + GenerateTriggerableTransition(disabledName, controller); + + AssetDatabase.ImportAsset(path); + + return controller; + } + + private static string GetSaveControllerPath(Selectable target) + { + var defaultName = target.gameObject.name; + var message = string.Format("Create a new animator for the game object '{0}':", defaultName); + return EditorUtility.SaveFilePanelInProject("New Animation Contoller", defaultName, "controller", message); + } + + private static void SetUpCurves(AnimationClip highlightedClip, AnimationClip pressedClip, string animationPath) + { + string[] channels = { "m_LocalScale.x", "m_LocalScale.y", "m_LocalScale.z" }; + + var highlightedKeys = new[] { new Keyframe(0f, 1f), new Keyframe(0.5f, 1.1f), new Keyframe(1f, 1f) }; + var highlightedCurve = new AnimationCurve(highlightedKeys); + foreach (var channel in channels) + AnimationUtility.SetEditorCurve(highlightedClip, EditorCurveBinding.FloatCurve(animationPath, typeof(Transform), channel), highlightedCurve); + + var pressedKeys = new[] { new Keyframe(0f, 1.15f) }; + var pressedCurve = new AnimationCurve(pressedKeys); + foreach (var channel in channels) + AnimationUtility.SetEditorCurve(pressedClip, EditorCurveBinding.FloatCurve(animationPath, typeof(Transform), channel), pressedCurve); + } + + private static string BuildAnimationPath(Selectable target) + { + // if no target don't hook up any curves. + var highlight = target.targetGraphic; + if (highlight == null) + return string.Empty; + + var startGo = highlight.gameObject; + var toFindGo = target.gameObject; + + var pathComponents = new Stack(); + while (toFindGo != startGo) + { + pathComponents.Push(startGo.name); + + // didn't exist in hierarchy! + if (startGo.transform.parent == null) + return string.Empty; + + startGo = startGo.transform.parent.gameObject; + } + + // calculate path + var animPath = new StringBuilder(); + if (pathComponents.Count > 0) + animPath.Append(pathComponents.Pop()); + + while (pathComponents.Count > 0) + animPath.Append("/").Append(pathComponents.Pop()); + + return animPath.ToString(); + } + + private static AnimationClip GenerateTriggerableTransition(string name, Animations.AnimatorController controller) + { + // Create the clip + var clip = Animations.AnimatorController.AllocateAnimatorClip(name); + AssetDatabase.AddObjectToAsset(clip, controller); + + // Create a state in the animatior controller for this clip + var state = controller.AddMotion(clip); + + // Add a transition property + controller.AddParameter(name, AnimatorControllerParameterType.Trigger); + + // Add an any state transition + var stateMachine = controller.layers[0].stateMachine; + var transition = stateMachine.AddAnyStateTransition(state); + transition.AddCondition(Animations.AnimatorConditionMode.If, 0, name); + return clip; + } + + private static void StaticOnSceneGUI(SceneView view) + { + if (!s_ShowNavigation) + return; + + for (int i = 0; i < Selectable.allSelectables.Count; i++) + { + DrawNavigationForSelectable(Selectable.allSelectables[i]); + } + } + + private static void DrawNavigationForSelectable(Selectable sel) + { + if (sel == null) + return; + + Transform transform = sel.transform; + bool active = Selection.transforms.Any(e => e == transform); + Handles.color = new Color(1.0f, 0.9f, 0.1f, active ? 1.0f : 0.4f); + DrawNavigationArrow(-Vector2.right, sel, sel.FindSelectableOnLeft()); + DrawNavigationArrow(Vector2.right, sel, sel.FindSelectableOnRight()); + DrawNavigationArrow(Vector2.up, sel, sel.FindSelectableOnUp()); + DrawNavigationArrow(-Vector2.up, sel, sel.FindSelectableOnDown()); + } + + const float kArrowThickness = 2.5f; + const float kArrowHeadSize = 1.2f; + + private static void DrawNavigationArrow(Vector2 direction, Selectable fromObj, Selectable toObj) + { + if (fromObj == null || toObj == null) + return; + Transform fromTransform = fromObj.transform; + Transform toTransform = toObj.transform; + + Vector2 sideDir = new Vector2(direction.y, -direction.x); + Vector3 fromPoint = fromTransform.TransformPoint(GetPointOnRectEdge(fromTransform as RectTransform, direction)); + Vector3 toPoint = toTransform.TransformPoint(GetPointOnRectEdge(toTransform as RectTransform, -direction)); + float fromSize = HandleUtility.GetHandleSize(fromPoint) * 0.05f; + float toSize = HandleUtility.GetHandleSize(toPoint) * 0.05f; + fromPoint += fromTransform.TransformDirection(sideDir) * fromSize; + toPoint += toTransform.TransformDirection(sideDir) * toSize; + float length = Vector3.Distance(fromPoint, toPoint); + Vector3 fromTangent = fromTransform.rotation * direction * length * 0.3f; + Vector3 toTangent = toTransform.rotation * -direction * length * 0.3f; + + Handles.DrawBezier(fromPoint, toPoint, fromPoint + fromTangent, toPoint + toTangent, Handles.color, null, kArrowThickness); + Handles.DrawAAPolyLine(kArrowThickness, toPoint, toPoint + toTransform.rotation * (-direction - sideDir) * toSize * kArrowHeadSize); + Handles.DrawAAPolyLine(kArrowThickness, toPoint, toPoint + toTransform.rotation * (-direction + sideDir) * toSize * kArrowHeadSize); + } + + private static Vector3 GetPointOnRectEdge(RectTransform rect, Vector2 dir) + { + if (rect == null) + return Vector3.zero; + if (dir != Vector2.zero) + dir /= Mathf.Max(Mathf.Abs(dir.x), Mathf.Abs(dir.y)); + dir = rect.rect.center + Vector2.Scale(rect.rect.size, dir * 0.5f); + return dir; + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/SelectableEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/SelectableEditor.cs.meta new file mode 100644 index 0000000..0384e82 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/SelectableEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 1d4d444b0a1bacb46a743e88cc4da1d0 +timeCreated: 1602119377 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/SelfControllerEditor.cs b/Assets/uGUI-2017.1/Editor/UI/SelfControllerEditor.cs new file mode 100644 index 0000000..4510d44 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/SelfControllerEditor.cs @@ -0,0 +1,35 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + public class SelfControllerEditor : Editor + { + static string s_Warning = "Parent has a type of layout group component. A child of a layout group should not have a {0} component, since it should be driven by the layout group."; + + public override void OnInspectorGUI() + { + bool anyHaveLayoutParent = false; + for (int i = 0; i < targets.Length; i++) + { + Component comp = (targets[i] as Component); + ILayoutIgnorer ignorer = comp.GetComponent(typeof(ILayoutIgnorer)) as ILayoutIgnorer; + if (ignorer != null && ignorer.ignoreLayout) + continue; + + RectTransform parent = comp.transform.parent as RectTransform; + if (parent != null) + { + Behaviour layoutGroup = parent.GetComponent(typeof(ILayoutGroup)) as Behaviour; + if (layoutGroup != null && layoutGroup.enabled) + { + anyHaveLayoutParent = true; + break; + } + } + } + if (anyHaveLayoutParent) + EditorGUILayout.HelpBox(string.Format(s_Warning, ObjectNames.NicifyVariableName(target.GetType().Name)), MessageType.Warning); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/SelfControllerEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/SelfControllerEditor.cs.meta new file mode 100644 index 0000000..a088542 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/SelfControllerEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 1c525819dc6fd8d43b99b1eaed430ddd +timeCreated: 1602119377 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/SliderEditor.cs b/Assets/uGUI-2017.1/Editor/UI/SliderEditor.cs new file mode 100644 index 0000000..f284648 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/SliderEditor.cs @@ -0,0 +1,88 @@ +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(Slider), true)] + [CanEditMultipleObjects] + public class SliderEditor : SelectableEditor + { + SerializedProperty m_Direction; + SerializedProperty m_FillRect; + SerializedProperty m_HandleRect; + SerializedProperty m_MinValue; + SerializedProperty m_MaxValue; + SerializedProperty m_WholeNumbers; + SerializedProperty m_Value; + SerializedProperty m_OnValueChanged; + + protected override void OnEnable() + { + base.OnEnable(); + m_FillRect = serializedObject.FindProperty("m_FillRect"); + m_HandleRect = serializedObject.FindProperty("m_HandleRect"); + m_Direction = serializedObject.FindProperty("m_Direction"); + m_MinValue = serializedObject.FindProperty("m_MinValue"); + m_MaxValue = serializedObject.FindProperty("m_MaxValue"); + m_WholeNumbers = serializedObject.FindProperty("m_WholeNumbers"); + m_Value = serializedObject.FindProperty("m_Value"); + m_OnValueChanged = serializedObject.FindProperty("m_OnValueChanged"); + } + + public override void OnInspectorGUI() + { + base.OnInspectorGUI(); + EditorGUILayout.Space(); + + serializedObject.Update(); + + EditorGUILayout.PropertyField(m_FillRect); + EditorGUILayout.PropertyField(m_HandleRect); + + if (m_FillRect.objectReferenceValue != null || m_HandleRect.objectReferenceValue != null) + { + EditorGUI.BeginChangeCheck(); + EditorGUILayout.PropertyField(m_Direction); + if (EditorGUI.EndChangeCheck()) + { + Slider.Direction direction = (Slider.Direction)m_Direction.enumValueIndex; + foreach (var obj in serializedObject.targetObjects) + { + Slider slider = obj as Slider; + slider.SetDirection(direction, true); + } + } + + EditorGUILayout.PropertyField(m_MinValue); + EditorGUILayout.PropertyField(m_MaxValue); + EditorGUILayout.PropertyField(m_WholeNumbers); + EditorGUILayout.Slider(m_Value, m_MinValue.floatValue, m_MaxValue.floatValue); + + bool warning = false; + foreach (var obj in serializedObject.targetObjects) + { + Slider slider = obj as Slider; + Slider.Direction dir = slider.direction; + if (dir == Slider.Direction.LeftToRight || dir == Slider.Direction.RightToLeft) + warning = (slider.navigation.mode != Navigation.Mode.Automatic && (slider.FindSelectableOnLeft() != null || slider.FindSelectableOnRight() != null)); + else + warning = (slider.navigation.mode != Navigation.Mode.Automatic && (slider.FindSelectableOnDown() != null || slider.FindSelectableOnUp() != null)); + } + + if (warning) + EditorGUILayout.HelpBox("The selected slider direction conflicts with navigation. Not all navigation options may work.", MessageType.Warning); + + // Draw the event notification options + EditorGUILayout.Space(); + EditorGUILayout.PropertyField(m_OnValueChanged); + } + else + { + EditorGUILayout.HelpBox("Specify a RectTransform for the slider fill or the slider handle or both. Each must have a parent RectTransform that it can slide within.", MessageType.Info); + } + + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/SliderEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/SliderEditor.cs.meta new file mode 100644 index 0000000..b313067 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/SliderEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 778a137b5ae337b4db4a47f1d34442b1 +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/SpriteDrawUtility.cs b/Assets/uGUI-2017.1/Editor/UI/SpriteDrawUtility.cs new file mode 100644 index 0000000..32b9498 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/SpriteDrawUtility.cs @@ -0,0 +1,200 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace UnityEditor.UI +{ + // Tools for the editor + internal class SpriteDrawUtility + { + static Texture2D s_ContrastTex; + + // Returns a usable texture that looks like a high-contrast checker board. + static Texture2D contrastTexture + { + get + { + if (s_ContrastTex == null) + s_ContrastTex = CreateCheckerTex( + new Color(0f, 0.0f, 0f, 0.5f), + new Color(1f, 1f, 1f, 0.5f)); + return s_ContrastTex; + } + } + + // Create a checker-background texture. + static Texture2D CreateCheckerTex(Color c0, Color c1) + { + Texture2D tex = new Texture2D(16, 16); + tex.name = "[Generated] Checker Texture"; + tex.hideFlags = HideFlags.DontSave; + + for (int y = 0; y < 8; ++y) for (int x = 0; x < 8; ++x) tex.SetPixel(x, y, c1); + for (int y = 8; y < 16; ++y) for (int x = 0; x < 8; ++x) tex.SetPixel(x, y, c0); + for (int y = 0; y < 8; ++y) for (int x = 8; x < 16; ++x) tex.SetPixel(x, y, c0); + for (int y = 8; y < 16; ++y) for (int x = 8; x < 16; ++x) tex.SetPixel(x, y, c1); + + tex.Apply(); + tex.filterMode = FilterMode.Point; + return tex; + } + + // Create a gradient texture. + static Texture2D CreateGradientTex() + { + Texture2D tex = new Texture2D(1, 16); + tex.name = "[Generated] Gradient Texture"; + tex.hideFlags = HideFlags.DontSave; + + Color c0 = new Color(1f, 1f, 1f, 0f); + Color c1 = new Color(1f, 1f, 1f, 0.4f); + + for (int i = 0; i < 16; ++i) + { + float f = Mathf.Abs((i / 15f) * 2f - 1f); + f *= f; + tex.SetPixel(0, i, Color.Lerp(c0, c1, f)); + } + + tex.Apply(); + tex.filterMode = FilterMode.Bilinear; + return tex; + } + + // Draws the tiled texture. Like GUI.DrawTexture() but tiled instead of stretched. + static void DrawTiledTexture(Rect rect, Texture tex) + { + float u = rect.width / tex.width; + float v = rect.height / tex.height; + + Rect texCoords = new Rect(0, 0, u, v); + TextureWrapMode originalMode = tex.wrapMode; + tex.wrapMode = TextureWrapMode.Repeat; + GUI.DrawTextureWithTexCoords(rect, tex, texCoords); + tex.wrapMode = originalMode; + } + + // Draw the specified Image. + public static void DrawSprite(Sprite sprite, Rect drawArea, Color color) + { + if (sprite == null) + return; + + Texture2D tex = sprite.texture; + if (tex == null) + return; + + Rect outer = sprite.rect; + Rect inner = outer; + inner.xMin += sprite.border.x; + inner.yMin += sprite.border.y; + inner.xMax -= sprite.border.z; + inner.yMax -= sprite.border.w; + + Vector4 uv4 = UnityEngine.Sprites.DataUtility.GetOuterUV(sprite); + Rect uv = new Rect(uv4.x, uv4.y, uv4.z - uv4.x, uv4.w - uv4.y); + Vector4 padding = UnityEngine.Sprites.DataUtility.GetPadding(sprite); + padding.x /= outer.width; + padding.y /= outer.height; + padding.z /= outer.width; + padding.w /= outer.height; + + DrawSprite(tex, drawArea, padding, outer, inner, uv, color, null); + } + + // Draw the specified Image. + public static void DrawSprite(Texture tex, Rect drawArea, Rect outer, Rect uv, Color color) + { + DrawSprite(tex, drawArea, Vector4.zero, outer, outer, uv, color, null); + } + + // Draw the specified Image. + private static void DrawSprite(Texture tex, Rect drawArea, Vector4 padding, Rect outer, Rect inner, Rect uv, Color color, Material mat) + { + // Create the texture rectangle that is centered inside rect. + Rect outerRect = drawArea; + outerRect.width = Mathf.Abs(outer.width); + outerRect.height = Mathf.Abs(outer.height); + + if (outerRect.width > 0f) + { + float f = drawArea.width / outerRect.width; + outerRect.width *= f; + outerRect.height *= f; + } + + if (drawArea.height > outerRect.height) + { + outerRect.y += (drawArea.height - outerRect.height) * 0.5f; + } + else if (outerRect.height > drawArea.height) + { + float f = drawArea.height / outerRect.height; + outerRect.width *= f; + outerRect.height *= f; + } + + if (drawArea.width > outerRect.width) + outerRect.x += (drawArea.width - outerRect.width) * 0.5f; + + // Draw the background + EditorGUI.DrawTextureTransparent(outerRect, null, ScaleMode.ScaleToFit, outer.width / outer.height); + + // Draw the Image + GUI.color = color; + + Rect paddedTexArea = new Rect( + outerRect.x + outerRect.width * padding.x, + outerRect.y + outerRect.height * padding.w, + outerRect.width - (outerRect.width * (padding.z + padding.x)), + outerRect.height - (outerRect.height * (padding.w + padding.y)) + ); + + if (mat == null) + { + GL.sRGBWrite = QualitySettings.activeColorSpace == ColorSpace.Linear; + GUI.DrawTextureWithTexCoords(paddedTexArea, tex, uv, true); + GL.sRGBWrite = false; + } + else + { + // NOTE: There is an issue in Unity that prevents it from clipping the drawn preview + // using BeginGroup/EndGroup, and there is no way to specify a UV rect... + EditorGUI.DrawPreviewTexture(paddedTexArea, tex, mat); + } + + // Draw the border indicator lines + GUI.BeginGroup(outerRect); + { + tex = contrastTexture; + GUI.color = Color.white; + + if (inner.xMin != outer.xMin) + { + float x = (inner.xMin - outer.xMin) / outer.width * outerRect.width - 1; + DrawTiledTexture(new Rect(x, 0f, 1f, outerRect.height), tex); + } + + if (inner.xMax != outer.xMax) + { + float x = (inner.xMax - outer.xMin) / outer.width * outerRect.width - 1; + DrawTiledTexture(new Rect(x, 0f, 1f, outerRect.height), tex); + } + + if (inner.yMin != outer.yMin) + { + // GUI.DrawTexture is top-left based rather than bottom-left + float y = (inner.yMin - outer.yMin) / outer.height * outerRect.height - 1; + DrawTiledTexture(new Rect(0f, outerRect.height - y, outerRect.width, 1f), tex); + } + + if (inner.yMax != outer.yMax) + { + float y = (inner.yMax - outer.yMin) / outer.height * outerRect.height - 1; + DrawTiledTexture(new Rect(0f, outerRect.height - y, outerRect.width, 1f), tex); + } + } + + GUI.EndGroup(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/SpriteDrawUtility.cs.meta b/Assets/uGUI-2017.1/Editor/UI/SpriteDrawUtility.cs.meta new file mode 100644 index 0000000..eafacaa --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/SpriteDrawUtility.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: fb3e0854e2906b14289d932ddbf67d55 +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/TextEditor.cs b/Assets/uGUI-2017.1/Editor/UI/TextEditor.cs new file mode 100644 index 0000000..b818f21 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/TextEditor.cs @@ -0,0 +1,40 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + // TODO REVIEW + // Have material live under text + // move stencil mask into effects *make an efects top level element like there is + // paragraph and character + + /// + /// Editor class used to edit UI Labels. + /// + + [CustomEditor(typeof(Text), true)] + [CanEditMultipleObjects] + public class TextEditor : GraphicEditor + { + SerializedProperty m_Text; + SerializedProperty m_FontData; + + protected override void OnEnable() + { + base.OnEnable(); + m_Text = serializedObject.FindProperty("m_Text"); + m_FontData = serializedObject.FindProperty("m_FontData"); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + EditorGUILayout.PropertyField(m_Text); + EditorGUILayout.PropertyField(m_FontData); + AppearanceControlsGUI(); + RaycastControlsGUI(); + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/TextEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/TextEditor.cs.meta new file mode 100644 index 0000000..04e20ed --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/TextEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: c6bec5fe73b6cdc4486c22e79e6ef095 +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/ToggleEditor.cs b/Assets/uGUI-2017.1/Editor/UI/ToggleEditor.cs new file mode 100644 index 0000000..632e4d0 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/ToggleEditor.cs @@ -0,0 +1,46 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(Toggle), true)] + [CanEditMultipleObjects] + public class ToggleEditor : SelectableEditor + { + SerializedProperty m_OnValueChangedProperty; + SerializedProperty m_TransitionProperty; + SerializedProperty m_GraphicProperty; + SerializedProperty m_GroupProperty; + SerializedProperty m_IsOnProperty; + + protected override void OnEnable() + { + base.OnEnable(); + + m_TransitionProperty = serializedObject.FindProperty("toggleTransition"); + m_GraphicProperty = serializedObject.FindProperty("graphic"); + m_GroupProperty = serializedObject.FindProperty("m_Group"); + m_IsOnProperty = serializedObject.FindProperty("m_IsOn"); + m_OnValueChangedProperty = serializedObject.FindProperty("onValueChanged"); + } + + public override void OnInspectorGUI() + { + base.OnInspectorGUI(); + EditorGUILayout.Space(); + + serializedObject.Update(); + EditorGUILayout.PropertyField(m_IsOnProperty); + EditorGUILayout.PropertyField(m_TransitionProperty); + EditorGUILayout.PropertyField(m_GraphicProperty); + EditorGUILayout.PropertyField(m_GroupProperty); + + EditorGUILayout.Space(); + + // Draw the event notification options + EditorGUILayout.PropertyField(m_OnValueChangedProperty); + + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/ToggleEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/ToggleEditor.cs.meta new file mode 100644 index 0000000..18f05c3 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/ToggleEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 5c004313ae1b2fb40986d6453e88b8bf +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.meta b/Assets/uGUI-2017.1/UnityEngine.UI.meta new file mode 100644 index 0000000..974250f --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e90c2c81193e4314ab3be0cc92d903b5 +folderAsset: yes +timeCreated: 1602119377 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: 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