diff --git a/Scripts/BoundTooltip/BoundTooltipTrigger.cs b/Scripts/BoundTooltip/BoundTooltipTrigger.cs deleted file mode 100644 index 415d70e..0000000 --- a/Scripts/BoundTooltip/BoundTooltipTrigger.cs +++ /dev/null @@ -1,54 +0,0 @@ -///Credit Martin Nerurkar // www.martin.nerurkar.de // www.sharkbombs.com -///Sourced from - http://www.sharkbombs.com/2015/02/10/tooltips-with-the-new-unity-ui-ugui/ -using UnityEngine.EventSystems; - -namespace UnityEngine.UI.Extensions -{ - [AddComponentMenu("UI/Extensions/Bound Tooltip/Tooltip Trigger")] - public class BoundTooltipTrigger : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, ISelectHandler, IDeselectHandler - { - [TextAreaAttribute] - public string text; - - public bool useMousePosition = false; - - public Vector3 offset; - - public void OnPointerEnter(PointerEventData eventData) - { - if (useMousePosition) - { - StartHover(new Vector3(eventData.position.x, eventData.position.y, 0f)); - } - else - { - StartHover(transform.position + offset); - } - } - - public void OnSelect(BaseEventData eventData) - { - StartHover(transform.position); - } - - public void OnPointerExit(PointerEventData eventData) - { - StopHover(); - } - - public void OnDeselect(BaseEventData eventData) - { - StopHover(); - } - - void StartHover(Vector3 position) - { - BoundTooltipItem.Instance.ShowTooltip(text, position); - } - - void StopHover() - { - BoundTooltipItem.Instance.HideTooltip(); - } - } -} diff --git a/Scripts/ImageExtended.cs b/Scripts/Effects/ImageExtended.cs similarity index 96% rename from Scripts/ImageExtended.cs rename to Scripts/Effects/ImageExtended.cs index 87a82d9..d88f7f8 100644 --- a/Scripts/ImageExtended.cs +++ b/Scripts/Effects/ImageExtended.cs @@ -253,14 +253,8 @@ namespace UnityEngine.UI.Extensions /// Update the UI renderer mesh. /// - protected override void OnPopulateMesh(Mesh toFill) + protected override void OnFillVBO(List vbo) { - List vbo = new List(); - using (var helper = new VertexHelper(toFill)) - { - helper.GetUIVertexStream(vbo); - } - switch (type) { case Type.Simple: @@ -276,12 +270,6 @@ namespace UnityEngine.UI.Extensions GenerateFilledSprite(vbo, m_PreserveAspect); break; } - - using (var helper = new VertexHelper()) - { - helper.AddUIVertexTriangleStream(vbo); - helper.FillMesh(toFill); - } } #region Various fill functions diff --git a/Scripts/ImageExtended.cs.meta b/Scripts/Effects/ImageExtended.cs.meta similarity index 100% rename from Scripts/ImageExtended.cs.meta rename to Scripts/Effects/ImageExtended.cs.meta diff --git a/Scripts/RaycastMask.cs b/Scripts/Effects/RaycastMask.cs similarity index 100% rename from Scripts/RaycastMask.cs rename to Scripts/Effects/RaycastMask.cs diff --git a/Scripts/RaycastMask.cs.meta b/Scripts/Effects/RaycastMask.cs.meta similarity index 100% rename from Scripts/RaycastMask.cs.meta rename to Scripts/Effects/RaycastMask.cs.meta diff --git a/Scripts/ToolTips.meta b/Scripts/ToolTips.meta new file mode 100644 index 0000000..669f459 --- /dev/null +++ b/Scripts/ToolTips.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 3941688ec5107f5479d09d503b6376c5 +folderAsset: yes +DefaultImporter: + userData: diff --git a/Scripts/BoundTooltip.meta b/Scripts/ToolTips/BoundTooltip.meta similarity index 100% rename from Scripts/BoundTooltip.meta rename to Scripts/ToolTips/BoundTooltip.meta diff --git a/Scripts/BoundTooltip/BoundTooltipItem.cs b/Scripts/ToolTips/BoundTooltip/BoundTooltipItem.cs similarity index 100% rename from Scripts/BoundTooltip/BoundTooltipItem.cs rename to Scripts/ToolTips/BoundTooltip/BoundTooltipItem.cs diff --git a/Scripts/BoundTooltip/BoundTooltipItem.cs.meta b/Scripts/ToolTips/BoundTooltip/BoundTooltipItem.cs.meta similarity index 100% rename from Scripts/BoundTooltip/BoundTooltipItem.cs.meta rename to Scripts/ToolTips/BoundTooltip/BoundTooltipItem.cs.meta diff --git a/Scripts/ToolTips/BoundTooltip/BoundTooltipTrigger.cs b/Scripts/ToolTips/BoundTooltip/BoundTooltipTrigger.cs new file mode 100644 index 0000000..9776722 --- /dev/null +++ b/Scripts/ToolTips/BoundTooltip/BoundTooltipTrigger.cs @@ -0,0 +1,39 @@ +///Credit Martin Nerurkar // www.martin.nerurkar.de // www.sharkbombs.com +///Sourced from - http://www.sharkbombs.com/2015/02/10/tooltips-with-the-new-unity-ui-ugui/ + +using UnityEngine.EventSystems; + +namespace UnityEngine.UI.Extensions +{ + [AddComponentMenu("UI/Extensions/Bound Tooltip/Tooltip Trigger")] + public class BoundTooltipTrigger : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, ISelectHandler, IDeselectHandler + { + public string text; + + public void OnPointerEnter(PointerEventData eventData) + { + StartHover(new Vector3(eventData.position.x, eventData.position.y, 0f)); + } + public void OnSelect(BaseEventData eventData) + { + StartHover(transform.position); + } + public void OnPointerExit(PointerEventData eventData) + { + StopHover(); + } + public void OnDeselect(BaseEventData eventData) + { + StopHover(); + } + + void StartHover(Vector3 position) + { + BoundTooltipItem.Instance.ShowTooltip(text, position); + } + void StopHover() + { + BoundTooltipItem.Instance.HideTooltip(); + } + } +} diff --git a/Scripts/BoundTooltip/BoundTooltipTrigger.cs.meta b/Scripts/ToolTips/BoundTooltip/BoundTooltipTrigger.cs.meta similarity index 100% rename from Scripts/BoundTooltip/BoundTooltipTrigger.cs.meta rename to Scripts/ToolTips/BoundTooltip/BoundTooltipTrigger.cs.meta diff --git a/Scripts/Utilities/HoverTooltip.cs b/Scripts/ToolTips/HoverTooltip.cs similarity index 100% rename from Scripts/Utilities/HoverTooltip.cs rename to Scripts/ToolTips/HoverTooltip.cs diff --git a/Scripts/Utilities/HoverTooltip.cs.meta b/Scripts/ToolTips/HoverTooltip.cs.meta similarity index 100% rename from Scripts/Utilities/HoverTooltip.cs.meta rename to Scripts/ToolTips/HoverTooltip.cs.meta diff --git a/Scripts/ToolTip.cs b/Scripts/ToolTips/ToolTip.cs similarity index 100% rename from Scripts/ToolTip.cs rename to Scripts/ToolTips/ToolTip.cs diff --git a/Scripts/ToolTip.cs.meta b/Scripts/ToolTips/ToolTip.cs.meta similarity index 100% rename from Scripts/ToolTip.cs.meta rename to Scripts/ToolTips/ToolTip.cs.meta diff --git a/Scripts/UISelectableExtension.cs b/Scripts/UISelectableExtension.cs deleted file mode 100644 index 17733b8..0000000 --- a/Scripts/UISelectableExtension.cs +++ /dev/null @@ -1,119 +0,0 @@ -/// Credit AriathTheWise -/// Sourced from - http://forum.unity3d.com/threads/scripts-useful-4-6-scripts-collection.264161/page-2#post-1796783 -/// Extended to include a HELD state that continually fires while the button is held down. -/// Refactored so it can be added to any button and expose the events in the editor. -/// Unselect fix by @Sfyne - -using UnityEngine.Events; -using UnityEngine.EventSystems; - -namespace UnityEngine.UI.Extensions -{ - /// - /// UIButton - /// - [AddComponentMenu("UI/Extensions/UI Selectable Extension")] - [RequireComponent(typeof(Selectable))] - public class UISelectableExtension : MonoBehaviour, IPointerDownHandler, IPointerUpHandler - { - #region Sub-Classes - [System.Serializable] - public class UIButtonEvent : UnityEvent { } - #endregion - - #region Events - [Tooltip("Event that fires when a button is initially pressed down")] - public UIButtonEvent OnButtonPress; - [Tooltip("Event that fires when a button is released")] - public UIButtonEvent OnButtonRelease; - [Tooltip("Event that continually fires while a button is held down")] - public UIButtonEvent OnButtonHeld; - #endregion - - private bool _pressed; - private PointerEventData _heldEventData; - - void IPointerDownHandler.OnPointerDown(PointerEventData eventData) - { - //Can't set the state as it's too locked down. - //DoStateTransition(SelectionState.Pressed, false); - - if (OnButtonPress != null) - { - OnButtonPress.Invoke(eventData.button); - } - _pressed = true; - _heldEventData = eventData; - } - - - void IPointerUpHandler.OnPointerUp(PointerEventData eventData) - { - //DoStateTransition(SelectionState.Normal, false); - - if (OnButtonRelease != null) - { - OnButtonRelease.Invoke(eventData.button); - } - _pressed = false; - _heldEventData = null; - } - - void Update() - { - if (!_pressed) - return; - - if (OnButtonHeld != null) - { - OnButtonHeld.Invoke(_heldEventData.button); - } - } - - /// - /// Test method to verify a control has been clicked - /// - public void TestClicked() - { - #if DEBUG || UNITY_EDITOR - Debug.Log("Control Clicked"); - #endif - } - - /// - /// Test method to verify a controll is pressed - /// - public void TestPressed() - { - #if DEBUG || UNITY_EDITOR - Debug.Log("Control Pressed"); - #endif - } - - /// - /// est method to verify if a control is released - /// - public void TestReleased() - { - #if DEBUG || UNITY_EDITOR - Debug.Log("Control Released"); - #endif - } - - /// - /// est method to verify if a control is being held - /// - public void TestHold() - { - #if DEBUG || UNITY_EDITOR - Debug.Log("Control Held"); - #endif - } - - //Fixed UISelectableExtension inactive bug (if gameObject becomes inactive while button is held down it never goes back to _pressed = false) - void OnDisable () - { - _pressed = false; - } - } -} \ No newline at end of file diff --git a/Scripts/InputFieldEnterSubmit.cs b/Scripts/Utilities/InputFieldEnterSubmit.cs similarity index 100% rename from Scripts/InputFieldEnterSubmit.cs rename to Scripts/Utilities/InputFieldEnterSubmit.cs diff --git a/Scripts/InputFieldEnterSubmit.cs.meta b/Scripts/Utilities/InputFieldEnterSubmit.cs.meta similarity index 100% rename from Scripts/InputFieldEnterSubmit.cs.meta rename to Scripts/Utilities/InputFieldEnterSubmit.cs.meta diff --git a/Scripts/InputFocus.cs b/Scripts/Utilities/InputFocus.cs similarity index 100% rename from Scripts/InputFocus.cs rename to Scripts/Utilities/InputFocus.cs diff --git a/Scripts/InputFocus.cs.meta b/Scripts/Utilities/InputFocus.cs.meta similarity index 100% rename from Scripts/InputFocus.cs.meta rename to Scripts/Utilities/InputFocus.cs.meta diff --git a/Scripts/ReturnKeyTriggersButton.cs b/Scripts/Utilities/ReturnKeyTriggersButton.cs similarity index 100% rename from Scripts/ReturnKeyTriggersButton.cs rename to Scripts/Utilities/ReturnKeyTriggersButton.cs diff --git a/Scripts/ReturnKeyTriggersButton.cs.meta b/Scripts/Utilities/ReturnKeyTriggersButton.cs.meta similarity index 100% rename from Scripts/ReturnKeyTriggersButton.cs.meta rename to Scripts/Utilities/ReturnKeyTriggersButton.cs.meta diff --git a/Scripts/ScrollRectEx.cs b/Scripts/Utilities/ScrollRectEx.cs similarity index 100% rename from Scripts/ScrollRectEx.cs rename to Scripts/Utilities/ScrollRectEx.cs diff --git a/Scripts/ScrollRectEx.cs.meta b/Scripts/Utilities/ScrollRectEx.cs.meta similarity index 100% rename from Scripts/ScrollRectEx.cs.meta rename to Scripts/Utilities/ScrollRectEx.cs.meta diff --git a/Scripts/ScrollRectExtensions.cs b/Scripts/Utilities/ScrollRectExtensions.cs similarity index 100% rename from Scripts/ScrollRectExtensions.cs rename to Scripts/Utilities/ScrollRectExtensions.cs diff --git a/Scripts/ScrollRectExtensions.cs.meta b/Scripts/Utilities/ScrollRectExtensions.cs.meta similarity index 100% rename from Scripts/ScrollRectExtensions.cs.meta rename to Scripts/Utilities/ScrollRectExtensions.cs.meta diff --git a/Scripts/ScrollRectLinker.cs b/Scripts/Utilities/ScrollRectLinker.cs similarity index 100% rename from Scripts/ScrollRectLinker.cs rename to Scripts/Utilities/ScrollRectLinker.cs diff --git a/Scripts/ScrollRectLinker.cs.meta b/Scripts/Utilities/ScrollRectLinker.cs.meta similarity index 100% rename from Scripts/ScrollRectLinker.cs.meta rename to Scripts/Utilities/ScrollRectLinker.cs.meta diff --git a/Scripts/ScrollRectTweener.cs b/Scripts/Utilities/ScrollRectTweener.cs similarity index 100% rename from Scripts/ScrollRectTweener.cs rename to Scripts/Utilities/ScrollRectTweener.cs diff --git a/Scripts/ScrollRectTweener.cs.meta b/Scripts/Utilities/ScrollRectTweener.cs.meta similarity index 100% rename from Scripts/ScrollRectTweener.cs.meta rename to Scripts/Utilities/ScrollRectTweener.cs.meta diff --git a/Scripts/UIScrollToSelection.cs b/Scripts/Utilities/UIScrollToSelection.cs similarity index 100% rename from Scripts/UIScrollToSelection.cs rename to Scripts/Utilities/UIScrollToSelection.cs diff --git a/Scripts/UIScrollToSelection.cs.meta b/Scripts/Utilities/UIScrollToSelection.cs.meta similarity index 100% rename from Scripts/UIScrollToSelection.cs.meta rename to Scripts/Utilities/UIScrollToSelection.cs.meta diff --git a/Scripts/UIScrollToSelectionXY.cs b/Scripts/Utilities/UIScrollToSelectionXY.cs similarity index 100% rename from Scripts/UIScrollToSelectionXY.cs rename to Scripts/Utilities/UIScrollToSelectionXY.cs diff --git a/Scripts/UIScrollToSelectionXY.cs.meta b/Scripts/Utilities/UIScrollToSelectionXY.cs.meta similarity index 100% rename from Scripts/UIScrollToSelectionXY.cs.meta rename to Scripts/Utilities/UIScrollToSelectionXY.cs.meta diff --git a/Scripts/Utilities/UISelectableExtension.cs b/Scripts/Utilities/UISelectableExtension.cs new file mode 100644 index 0000000..0f73cf1 --- /dev/null +++ b/Scripts/Utilities/UISelectableExtension.cs @@ -0,0 +1,112 @@ +/// Credit AriathTheWise +/// Sourced from - http://forum.unity3d.com/threads/scripts-useful-4-6-scripts-collection.264161/page-2#post-1796783 +/// Extended to include a HELD state that continually fires while the button is held down. +/// Refactored so it can be added to any button and expose the events in the editor. + +using UnityEngine.Events; +using UnityEngine.EventSystems; + +namespace UnityEngine.UI.Extensions +{ + /// + /// UIButton + /// + [AddComponentMenu("UI/Extensions/UI Selectable Extension")] + [RequireComponent(typeof(Selectable))] + public class UISelectableExtension : MonoBehaviour, IPointerDownHandler, IPointerUpHandler + { + #region Sub-Classes + [System.Serializable] + public class UIButtonEvent : UnityEvent { } + #endregion + + #region Events + [Tooltip("Event that fires when a button is initially pressed down")] + public UIButtonEvent OnButtonPress; + [Tooltip("Event that fires when a button is released")] + public UIButtonEvent OnButtonRelease; + [Tooltip("Event that continually fires while a button is held down")] + public UIButtonEvent OnButtonHeld; + #endregion + + private bool _pressed; + private PointerEventData _heldEventData; + + void IPointerDownHandler.OnPointerDown(PointerEventData eventData) + { + //Can't set the state as it's too locked down. + //DoStateTransition(SelectionState.Pressed, false); + + if (OnButtonPress != null) + { + OnButtonPress.Invoke(eventData.button); + } + _pressed = true; + _heldEventData = eventData; + } + + + void IPointerUpHandler.OnPointerUp(PointerEventData eventData) + { + //DoStateTransition(SelectionState.Normal, false); + + if (OnButtonRelease != null) + { + OnButtonRelease.Invoke(eventData.button); + } + _pressed = false; + _heldEventData = null; + } + + void Update() + { + if (!_pressed) + return; + + if (OnButtonHeld != null) + { + OnButtonHeld.Invoke(_heldEventData.button); + } + } + + /// + /// Test method to verify a control has been clicked + /// + public void TestClicked() + { + #if DEBUG || UNITY_EDITOR + Debug.Log("Control Clicked"); + #endif + } + + /// + /// Test method to verify a controll is pressed + /// + public void TestPressed() + { + #if DEBUG || UNITY_EDITOR + Debug.Log("Control Pressed"); + #endif + } + + /// + /// est method to verify if a control is released + /// + public void TestReleased() + { + #if DEBUG || UNITY_EDITOR + Debug.Log("Control Released"); + #endif + } + + /// + /// est method to verify if a control is being held + /// + public void TestHold() + { + #if DEBUG || UNITY_EDITOR + Debug.Log("Control Held"); + #endif + } + } +} \ No newline at end of file diff --git a/Scripts/UISelectableExtension.cs.meta b/Scripts/Utilities/UISelectableExtension.cs.meta similarity index 53% rename from Scripts/UISelectableExtension.cs.meta rename to Scripts/Utilities/UISelectableExtension.cs.meta index 24ea92b..da3ac74 100644 --- a/Scripts/UISelectableExtension.cs.meta +++ b/Scripts/Utilities/UISelectableExtension.cs.meta @@ -1,12 +1,8 @@ fileFormatVersion: 2 -guid: 2bdfd6b4084989d41ba560bd1b72cbda -timeCreated: 1441922219 -licenseType: Pro +guid: 6bb501adc62c7394fae41ae7a6032eb3 MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: - assetBundleName: - assetBundleVariant: