Merge upstream re-org from 4.6

--HG--
branch : develop_5.3
release
Simon (darkside) Jackson 2015-12-23 20:40:49 +00:00
commit 3b37f7805b
40 changed files with 123 additions and 134 deletions

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 26d9c9fa4e5a13747a6ad9c3fedb57c8 guid: 494907d85b5e56a49884a914adc358a5
timeCreated: 1440851346 timeCreated: 1440851346
licenseType: Pro licenseType: Pro
MonoImporter: MonoImporter:

View File

@ -82,10 +82,10 @@ namespace UnityEngine.UI.Extensions
} }
return vbo; return vbo;
} }
protected override void OnPopulateMesh(Mesh toFill)
protected override void OnPopulateMesh(VertexHelper vh)
{ {
toFill.Clear(); vh.Clear();
var vbo = new VertexHelper(toFill);
Vector2 prevX = Vector2.zero; Vector2 prevX = Vector2.zero;
Vector2 prevY = Vector2.zero; Vector2 prevY = Vector2.zero;
@ -131,12 +131,7 @@ namespace UnityEngine.UI.Extensions
} }
prevX = pos1; prevX = pos1;
prevY = pos2; prevY = pos2;
vbo.AddUIVertexQuad(SetVbo(new[] { pos0, pos1, pos2, pos3 }, new[] { uv0, uv1, uv2, uv3 })); vh.AddUIVertexQuad(SetVbo(new[] { pos0, pos1, pos2, pos3 }, new[] { uv0, uv1, uv2, uv3 }));
}
if (vbo.currentVertCount > 3)
{
vbo.FillMesh(toFill);
} }
} }
} }

5
Scripts/ToolTips.meta Normal file
View File

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 3941688ec5107f5479d09d503b6376c5
folderAsset: yes
DefaultImporter:
userData:

View File

@ -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
{
/// <summary>
/// UIButton
/// </summary>
[AddComponentMenu("UI/Extensions/UI Selectable Extension")]
[RequireComponent(typeof(Selectable))]
public class UISelectableExtension : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
#region Sub-Classes
[System.Serializable]
public class UIButtonEvent : UnityEvent<PointerEventData.InputButton> { }
#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);
}
}
/// <summary>
/// Test method to verify a control has been clicked
/// </summary>
public void TestClicked()
{
#if DEBUG || UNITY_EDITOR
Debug.Log("Control Clicked");
#endif
}
/// <summary>
/// Test method to verify a controll is pressed
/// </summary>
public void TestPressed()
{
#if DEBUG || UNITY_EDITOR
Debug.Log("Control Pressed");
#endif
}
/// <summary>
/// est method to verify if a control is released
/// </summary>
public void TestReleased()
{
#if DEBUG || UNITY_EDITOR
Debug.Log("Control Released");
#endif
}
/// <summary>
/// est method to verify if a control is being held
/// </summary>
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;
}
}
}

View File

@ -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
{
/// <summary>
/// UIButton
/// </summary>
[AddComponentMenu("UI/Extensions/UI Selectable Extension")]
[RequireComponent(typeof(Selectable))]
public class UISelectableExtension : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
#region Sub-Classes
[System.Serializable]
public class UIButtonEvent : UnityEvent<PointerEventData.InputButton> { }
#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);
}
}
/// <summary>
/// Test method to verify a control has been clicked
/// </summary>
public void TestClicked()
{
#if DEBUG || UNITY_EDITOR
Debug.Log("Control Clicked");
#endif
}
/// <summary>
/// Test method to verify a controll is pressed
/// </summary>
public void TestPressed()
{
#if DEBUG || UNITY_EDITOR
Debug.Log("Control Pressed");
#endif
}
/// <summary>
/// est method to verify if a control is released
/// </summary>
public void TestReleased()
{
#if DEBUG || UNITY_EDITOR
Debug.Log("Control Released");
#endif
}
/// <summary>
/// est method to verify if a control is being held
/// </summary>
public void TestHold()
{
#if DEBUG || UNITY_EDITOR
Debug.Log("Control Held");
#endif
}
}
}

View File

@ -1,12 +1,8 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 2bdfd6b4084989d41ba560bd1b72cbda guid: 6bb501adc62c7394fae41ae7a6032eb3
timeCreated: 1441922219
licenseType: Pro
MonoImporter: MonoImporter:
serializedVersion: 2 serializedVersion: 2
defaultReferences: [] defaultReferences: []
executionOrder: 0 executionOrder: 0
icon: {instanceID: 0} icon: {instanceID: 0}
userData: userData:
assetBundleName:
assetBundleVariant: