Tidy up post merge

--HG--
branch : develop_5.2
pull/413/head
Simon (darkside) Jackson 2015-12-23 20:30:08 +00:00
parent d187674e00
commit 90cafab785
3 changed files with 130 additions and 96 deletions

View File

@ -253,8 +253,14 @@ namespace UnityEngine.UI.Extensions
/// Update the UI renderer mesh. /// Update the UI renderer mesh.
/// </summary> /// </summary>
protected override void OnFillVBO(List<UIVertex> vbo) protected override void OnPopulateMesh(Mesh toFill)
{ {
List<UIVertex> vbo = new List<UIVertex>();
using (var helper = new VertexHelper(toFill))
{
helper.GetUIVertexStream(vbo);
}
switch (type) switch (type)
{ {
case Type.Simple: case Type.Simple:
@ -270,6 +276,12 @@ namespace UnityEngine.UI.Extensions
GenerateFilledSprite(vbo, m_PreserveAspect); GenerateFilledSprite(vbo, m_PreserveAspect);
break; break;
} }
using (var helper = new VertexHelper())
{
helper.AddUIVertexTriangleStream(vbo);
helper.FillMesh(toFill);
}
} }
#region Various fill functions #region Various fill functions

View File

@ -1,39 +1,54 @@
///Credit Martin Nerurkar // www.martin.nerurkar.de // www.sharkbombs.com ///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/ ///Sourced from - http://www.sharkbombs.com/2015/02/10/tooltips-with-the-new-unity-ui-ugui/
using UnityEngine.EventSystems;
using UnityEngine.EventSystems;
namespace UnityEngine.UI.Extensions
namespace UnityEngine.UI.Extensions {
{ [AddComponentMenu("UI/Extensions/Bound Tooltip/Tooltip Trigger")]
[AddComponentMenu("UI/Extensions/Bound Tooltip/Tooltip Trigger")] public class BoundTooltipTrigger : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, ISelectHandler, IDeselectHandler
public class BoundTooltipTrigger : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, ISelectHandler, IDeselectHandler {
{ [TextAreaAttribute]
public string text; public string text;
public void OnPointerEnter(PointerEventData eventData) public bool useMousePosition = false;
{
StartHover(new Vector3(eventData.position.x, eventData.position.y, 0f)); public Vector3 offset;
}
public void OnSelect(BaseEventData eventData) public void OnPointerEnter(PointerEventData eventData)
{ {
StartHover(transform.position); if (useMousePosition)
} {
public void OnPointerExit(PointerEventData eventData) StartHover(new Vector3(eventData.position.x, eventData.position.y, 0f));
{ }
StopHover(); else
} {
public void OnDeselect(BaseEventData eventData) StartHover(transform.position + offset);
{ }
StopHover(); }
}
public void OnSelect(BaseEventData eventData)
void StartHover(Vector3 position) {
{ StartHover(transform.position);
BoundTooltipItem.Instance.ShowTooltip(text, position); }
}
void StopHover() public void OnPointerExit(PointerEventData eventData)
{ {
BoundTooltipItem.Instance.HideTooltip(); StopHover();
} }
}
} public void OnDeselect(BaseEventData eventData)
{
StopHover();
}
void StartHover(Vector3 position)
{
BoundTooltipItem.Instance.ShowTooltip(text, position);
}
void StopHover()
{
BoundTooltipItem.Instance.HideTooltip();
}
}
}

View File

@ -2,6 +2,7 @@
/// Sourced from - http://forum.unity3d.com/threads/scripts-useful-4-6-scripts-collection.264161/page-2#post-1796783 /// 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. /// 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. /// 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.Events;
using UnityEngine.EventSystems; using UnityEngine.EventSystems;
@ -21,27 +22,27 @@ namespace UnityEngine.UI.Extensions
#endregion #endregion
#region Events #region Events
[Tooltip("Event that fires when a button is initially pressed down")] [Tooltip("Event that fires when a button is initially pressed down")]
public UIButtonEvent OnButtonPress; public UIButtonEvent OnButtonPress;
[Tooltip("Event that fires when a button is released")] [Tooltip("Event that fires when a button is released")]
public UIButtonEvent OnButtonRelease; public UIButtonEvent OnButtonRelease;
[Tooltip("Event that continually fires while a button is held down")] [Tooltip("Event that continually fires while a button is held down")]
public UIButtonEvent OnButtonHeld; public UIButtonEvent OnButtonHeld;
#endregion #endregion
private bool _pressed; private bool _pressed;
private PointerEventData _heldEventData; private PointerEventData _heldEventData;
void IPointerDownHandler.OnPointerDown(PointerEventData eventData) void IPointerDownHandler.OnPointerDown(PointerEventData eventData)
{ {
//Can't set the state as it's too locked down. //Can't set the state as it's too locked down.
//DoStateTransition(SelectionState.Pressed, false); //DoStateTransition(SelectionState.Pressed, false);
if (OnButtonPress != null) if (OnButtonPress != null)
{ {
OnButtonPress.Invoke(eventData.button); OnButtonPress.Invoke(eventData.button);
} }
_pressed = true; _pressed = true;
_heldEventData = eventData; _heldEventData = eventData;
} }
@ -54,59 +55,65 @@ namespace UnityEngine.UI.Extensions
{ {
OnButtonRelease.Invoke(eventData.button); OnButtonRelease.Invoke(eventData.button);
} }
_pressed = false; _pressed = false;
_heldEventData = null; _heldEventData = null;
} }
void Update() void Update()
{ {
if (!_pressed) if (!_pressed)
return; return;
if (OnButtonHeld != null) if (OnButtonHeld != null)
{ {
OnButtonHeld.Invoke(_heldEventData.button); OnButtonHeld.Invoke(_heldEventData.button);
} }
} }
/// <summary> /// <summary>
/// Test method to verify a control has been clicked /// Test method to verify a control has been clicked
/// </summary> /// </summary>
public void TestClicked() public void TestClicked()
{ {
#if DEBUG || UNITY_EDITOR #if DEBUG || UNITY_EDITOR
Debug.Log("Control Clicked"); Debug.Log("Control Clicked");
#endif #endif
} }
/// <summary> /// <summary>
/// Test method to verify a controll is pressed /// Test method to verify a controll is pressed
/// </summary> /// </summary>
public void TestPressed() public void TestPressed()
{ {
#if DEBUG || UNITY_EDITOR #if DEBUG || UNITY_EDITOR
Debug.Log("Control Pressed"); Debug.Log("Control Pressed");
#endif #endif
} }
/// <summary> /// <summary>
/// est method to verify if a control is released /// est method to verify if a control is released
/// </summary> /// </summary>
public void TestReleased() public void TestReleased()
{ {
#if DEBUG || UNITY_EDITOR #if DEBUG || UNITY_EDITOR
Debug.Log("Control Released"); Debug.Log("Control Released");
#endif #endif
} }
/// <summary> /// <summary>
/// est method to verify if a control is being held /// est method to verify if a control is being held
/// </summary> /// </summary>
public void TestHold() public void TestHold()
{ {
#if DEBUG || UNITY_EDITOR #if DEBUG || UNITY_EDITOR
Debug.Log("Control Held"); Debug.Log("Control Held");
#endif #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;
}
} }
} }