First pass 1.3 updates:
* SelectableScaler.cs * MonoSpacing * MultiTouchScrollRect.cs * BezierLineRendererEditor.cs * WIP - DropDownList / AutoCompleteComboBoxpull/413/head
parent
7824978a8f
commit
a09a5b5322
|
@ -0,0 +1,54 @@
|
||||||
|
///Credit Jason Horsburgh
|
||||||
|
///Sourced from - https://bitbucket.org/UnityUIExtensions/unity-ui-extensions/issues/127/uilinerenderer-mesh-not-updating-in-editor
|
||||||
|
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI.Extensions;
|
||||||
|
|
||||||
|
namespace UnityEngine.UI.Extensions
|
||||||
|
{
|
||||||
|
[CustomEditor(typeof(UILineRenderer))]
|
||||||
|
public class BezierLineRendererEditor : Editor
|
||||||
|
{
|
||||||
|
void OnSceneGUI()
|
||||||
|
{
|
||||||
|
UILineRenderer curveRenderer = target as UILineRenderer;
|
||||||
|
|
||||||
|
if (!curveRenderer && curveRenderer.Points.Length < 2)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var oldMatrix = Handles.matrix;
|
||||||
|
var transform = curveRenderer.GetComponent<RectTransform>();
|
||||||
|
//Pivot must be 0,0 to edit
|
||||||
|
transform.pivot = Vector2.zero;
|
||||||
|
Handles.matrix = transform.localToWorldMatrix;
|
||||||
|
|
||||||
|
var points = curveRenderer.Points;
|
||||||
|
|
||||||
|
for (int i = 0; i < points.Length - 1; i += 2)
|
||||||
|
{
|
||||||
|
Handles.DrawLine(points[i], points[i + 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < points.Length; ++i)
|
||||||
|
{
|
||||||
|
using (var check = new EditorGUI.ChangeCheckScope())
|
||||||
|
{
|
||||||
|
var p = Handles.PositionHandle(points[i], Quaternion.identity);
|
||||||
|
|
||||||
|
if (check.changed)
|
||||||
|
{
|
||||||
|
Undo.RecordObject(curveRenderer, "Changed Curve Position");
|
||||||
|
curveRenderer.Points[i] = p;
|
||||||
|
curveRenderer.transform.gameObject.SetActive(false);
|
||||||
|
curveRenderer.transform.gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Handles.matrix = oldMatrix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4ef6a0d3c3259384982ae3974fe7e618
|
||||||
|
timeCreated: 1492258093
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Binary file not shown.
|
@ -73,49 +73,12 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool interactible
|
|
||||||
{
|
|
||||||
get { return _mainInput.interactable || _arrow_Button.interactable; }
|
|
||||||
private set {
|
|
||||||
_mainInput.interactable = value;
|
|
||||||
_arrow_Button.interactable = value;
|
|
||||||
if (!value && _isPanelActive) {
|
|
||||||
ToggleDropdownPanel (false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[SerializeField]
|
|
||||||
//I couldn't come up with a better name
|
|
||||||
private bool _technicallyInteractible = true;
|
|
||||||
public bool TechnicallyInteractible
|
|
||||||
{
|
|
||||||
get { return _technicallyInteractible; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_technicallyInteractible = value;
|
|
||||||
interactible = _technicallyInteractible && (AvailableOptions.Count > 0 || _remainInteractableIfEmpty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[SerializeField]
|
|
||||||
private bool _remainInteractableIfEmpty = true;
|
|
||||||
public bool RemainInteractableIfEmpty
|
|
||||||
{
|
|
||||||
get { return _remainInteractableIfEmpty; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_remainInteractableIfEmpty = value;
|
|
||||||
interactible = _technicallyInteractible && (AvailableOptions.Count > 0 || _remainInteractableIfEmpty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SelectFirstItemOnStart = false;
|
public bool SelectFirstItemOnStart = false;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private bool _ChangeInputTextColorBasedOnMatchingItems = false;
|
private bool _ChangeInputTextColorBasedOnMatchingItems = false;
|
||||||
public bool ChangeInputTextColorBasedOnMatchingItems{
|
public bool ChangeInputTextColorBasedOnMatchingItems{
|
||||||
get { return _remainInteractableIfEmpty; }
|
get { return _ChangeInputTextColorBasedOnMatchingItems; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_ChangeInputTextColorBasedOnMatchingItems = value;
|
_ChangeInputTextColorBasedOnMatchingItems = value;
|
||||||
|
@ -288,7 +251,6 @@ namespace UnityEngine.UI.Extensions
|
||||||
panelObjects[_panelItems[i]] = itemObjs[i];
|
panelObjects[_panelItems[i]] = itemObjs[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
interactible = _technicallyInteractible && (AvailableOptions.Count > 0 || _remainInteractableIfEmpty);
|
|
||||||
SetInputTextColor ();
|
SetInputTextColor ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: ef22b091ebae52c47aa3e86ad9040c05
|
guid: ef22b091ebae52c47aa3e86ad9040c05
|
||||||
|
timeCreated: 1492278993
|
||||||
|
licenseType: Free
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
|
@ -70,42 +70,6 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool interactible
|
|
||||||
{
|
|
||||||
get { return _mainButton.btn.interactable; }
|
|
||||||
private set {
|
|
||||||
_mainButton.btn.interactable = value;
|
|
||||||
if (!value && _isPanelActive) {
|
|
||||||
ToggleDropdownPanel (false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[SerializeField]
|
|
||||||
//I couldn't come up with a better name
|
|
||||||
private bool _technicallyInteractible = true;
|
|
||||||
public bool TechnicallyInteractible
|
|
||||||
{
|
|
||||||
get { return _technicallyInteractible; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_technicallyInteractible = value;
|
|
||||||
interactible = _technicallyInteractible && (Items.Count > 0 || _remainInteractableIfEmpty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[SerializeField]
|
|
||||||
private bool _remainInteractableIfEmpty = true;
|
|
||||||
public bool RemainInteractableIfEmpty
|
|
||||||
{
|
|
||||||
get { return _remainInteractableIfEmpty; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_remainInteractableIfEmpty = value;
|
|
||||||
interactible = _technicallyInteractible && (Items.Count > 0 || _remainInteractableIfEmpty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SelectFirstItemOnStart = false;
|
public bool SelectFirstItemOnStart = false;
|
||||||
|
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
|
@ -241,7 +205,6 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
_panelItems[i].gameobject.SetActive(i < Items.Count);// if we have more thanks in the panel than Items in the list hide them
|
_panelItems[i].gameobject.SetActive(i < Items.Count);// if we have more thanks in the panel than Items in the list hide them
|
||||||
}
|
}
|
||||||
interactible = _technicallyInteractible && (Items.Count > 0 || _remainInteractableIfEmpty);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnItemClicked(int indx)
|
private void OnItemClicked(int indx)
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 7a00cad80d8a47b438b394bebe77d0d2
|
guid: 7a00cad80d8a47b438b394bebe77d0d2
|
||||||
|
timeCreated: 1492278993
|
||||||
|
licenseType: Free
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
|
@ -1,15 +1,12 @@
|
||||||
/// Credit Erdener Gonenc - @PixelEnvision
|
/// Credit Erdener Gonenc - @PixelEnvision
|
||||||
/*USAGE: Simply use that instead of the regular ScrollRect */
|
/*USAGE: Simply use that instead of the regular ScrollRect */
|
||||||
|
|
||||||
using System;
|
|
||||||
using UnityEngine.EventSystems;
|
|
||||||
|
|
||||||
namespace UnityEngine.UI.Extensions
|
namespace UnityEngine.UI.Extensions
|
||||||
{
|
{
|
||||||
[AddComponentMenu ("UI/Extensions/ScrollRectMultiTouchFix")]
|
[AddComponentMenu ("UI/Extensions/MultiTouchScrollRect")]
|
||||||
public class ScrollRectMultiTouchFix : ScrollRect
|
public class MultiTouchScrollRect : ScrollRect
|
||||||
{
|
{
|
||||||
|
|
||||||
private int pid = -100;
|
private int pid = -100;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -38,6 +35,5 @@ namespace UnityEngine.UI.Extensions
|
||||||
pid = -100;
|
pid = -100;
|
||||||
base.OnEndDrag (eventData);
|
base.OnEndDrag (eventData);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9f2bebd34aaa76541b97e61752a7d262
|
||||||
|
timeCreated: 1492273203
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -1,4 +1,4 @@
|
||||||
/// Credit herbst / derived from LetterSpacing by Deeperbeige
|
/// Credit herbst / derived from LetterSpacing by Deeperbeige
|
||||||
/// Sourced from - http://forum.unity3d.com/threads/adjustable-character-spacing-free-script.288277/
|
/// Sourced from - http://forum.unity3d.com/threads/adjustable-character-spacing-free-script.288277/
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
@ -46,30 +46,42 @@ using System.Collections.Generic;
|
||||||
namespace UnityEngine.UI.Extensions
|
namespace UnityEngine.UI.Extensions
|
||||||
{
|
{
|
||||||
[AddComponentMenu("UI/Effects/Extensions/Mono Spacing")]
|
[AddComponentMenu("UI/Effects/Extensions/Mono Spacing")]
|
||||||
|
[RequireComponent(typeof(Text))]
|
||||||
|
[RequireComponent(typeof(RectTransform))]
|
||||||
///Summary
|
///Summary
|
||||||
/// Note, Vertex Count has changed in 5.2.1+, is now 6 (two tris) instead of 4 (tri strip).
|
/// Note, Vertex Count has changed in 5.2.1+, is now 6 (two tris) instead of 4 (tri strip).
|
||||||
public class MonoSpacing : BaseMeshEffect
|
public class MonoSpacing : BaseMeshEffect
|
||||||
{
|
{
|
||||||
public bool useHalfCharWidth = false;
|
|
||||||
public float halfCharWidth = 1;
|
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private float m_spacing = 0f;
|
private float m_spacing = 0f;
|
||||||
|
public float HalfCharWidth = 1;
|
||||||
|
public bool UseHalfCharWidth = false;
|
||||||
|
|
||||||
RectTransform rectTransform;
|
private RectTransform rectTransform;
|
||||||
|
private Text text;
|
||||||
|
|
||||||
protected MonoSpacing() { }
|
protected MonoSpacing() { }
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
protected override void Awake()
|
||||||
protected override void OnValidate()
|
{
|
||||||
|
text = GetComponent<Text>();
|
||||||
|
if (text == null)
|
||||||
|
{
|
||||||
|
Debug.LogWarning("MonoSpacing: Missing Text component");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
rectTransform = text.GetComponent<RectTransform>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
protected override void OnValidate()
|
||||||
{
|
{
|
||||||
spacing = m_spacing;
|
Spacing = m_spacing;
|
||||||
rectTransform = GetComponent<Text>().GetComponent<RectTransform>();
|
|
||||||
base.OnValidate();
|
base.OnValidate();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public float spacing
|
public float Spacing
|
||||||
{
|
{
|
||||||
get { return m_spacing; }
|
get { return m_spacing; }
|
||||||
set
|
set
|
||||||
|
@ -86,17 +98,10 @@ namespace UnityEngine.UI.Extensions
|
||||||
|
|
||||||
List<UIVertex> verts = new List<UIVertex>();
|
List<UIVertex> verts = new List<UIVertex>();
|
||||||
vh.GetUIVertexStream(verts);
|
vh.GetUIVertexStream(verts);
|
||||||
|
|
||||||
Text text = GetComponent<Text>();
|
|
||||||
if (text == null)
|
|
||||||
{
|
|
||||||
Debug.LogWarning("MonoSpacing: Missing Text component");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
string[] lines = text.text.Split('\n');
|
string[] lines = text.text.Split('\n');
|
||||||
// Vector3 pos;
|
// Vector3 pos;
|
||||||
float letterOffset = spacing * (float)text.fontSize / 100f;
|
float letterOffset = Spacing * (float)text.fontSize / 100f;
|
||||||
float alignmentFactor = 0;
|
float alignmentFactor = 0;
|
||||||
int glyphIdx = 0;
|
int glyphIdx = 0;
|
||||||
|
|
||||||
|
@ -149,7 +154,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
|
|
||||||
// pos = Vector3.right * (letterOffset * (charIdx) - lineOffset);
|
// pos = Vector3.right * (letterOffset * (charIdx) - lineOffset);
|
||||||
float charWidth = (vert2.position - vert1.position).x;
|
float charWidth = (vert2.position - vert1.position).x;
|
||||||
var smallChar = useHalfCharWidth && (charWidth < halfCharWidth);
|
var smallChar = UseHalfCharWidth && (charWidth < HalfCharWidth);
|
||||||
|
|
||||||
var smallCharOffset = smallChar ? -letterOffset/4 : 0;
|
var smallCharOffset = smallChar ? -letterOffset/4 : 0;
|
||||||
|
|
||||||
|
@ -182,4 +187,4 @@ namespace UnityEngine.UI.Extensions
|
||||||
vh.AddUIVertexTriangleStream(verts);
|
vh.AddUIVertexTriangleStream(verts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
///Credit Tomek S
|
||||||
|
///Sourced from - https://pastebin.com/NXYu37jC
|
||||||
|
|
||||||
|
using System.Collections;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
|
namespace UnityEngine.UI.Extensions
|
||||||
|
{
|
||||||
|
[AddComponentMenu("UI/Extensions/Selectable Scalar")]
|
||||||
|
[RequireComponent(typeof(Button))]
|
||||||
|
public class SelectableScaler : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
|
||||||
|
{
|
||||||
|
public AnimationCurve animCurve;
|
||||||
|
[Tooltip("Animation speed multiplier")]
|
||||||
|
public float speed = 1;
|
||||||
|
private Vector3 initScale;
|
||||||
|
public Transform target;
|
||||||
|
|
||||||
|
Selectable selectable;
|
||||||
|
public Selectable Target
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (selectable == null)
|
||||||
|
selectable = GetComponent<Selectable>();
|
||||||
|
|
||||||
|
return selectable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Use this for initialization
|
||||||
|
void Awake()
|
||||||
|
{
|
||||||
|
if (target == null)
|
||||||
|
target = transform;
|
||||||
|
|
||||||
|
initScale = target.localScale;
|
||||||
|
}
|
||||||
|
void OnEnable()
|
||||||
|
{
|
||||||
|
target.localScale = initScale;
|
||||||
|
}
|
||||||
|
public void OnPointerDown(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
if (Target != null && !Target.interactable)
|
||||||
|
return;
|
||||||
|
|
||||||
|
StopCoroutine("ScaleOUT");
|
||||||
|
StartCoroutine("ScaleIN");
|
||||||
|
}
|
||||||
|
public void OnPointerUp(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
if (Target != null && !Target.interactable)
|
||||||
|
return;
|
||||||
|
|
||||||
|
StopCoroutine("ScaleIN");
|
||||||
|
StartCoroutine("ScaleOUT");
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator ScaleIN()
|
||||||
|
{
|
||||||
|
if (animCurve.keys.Length > 0)
|
||||||
|
{
|
||||||
|
target.localScale = initScale;
|
||||||
|
float t = 0;
|
||||||
|
float maxT = animCurve.keys[animCurve.length - 1].time;
|
||||||
|
|
||||||
|
while (t < maxT)
|
||||||
|
{
|
||||||
|
t += speed * Time.unscaledDeltaTime;
|
||||||
|
target.localScale = Vector3.one * animCurve.Evaluate(t);
|
||||||
|
yield return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IEnumerator ScaleOUT()
|
||||||
|
{
|
||||||
|
if (animCurve.keys.Length > 0)
|
||||||
|
{
|
||||||
|
//target.localScale = initScale;
|
||||||
|
float t = 0;
|
||||||
|
float maxT = animCurve.keys[animCurve.length - 1].time;
|
||||||
|
|
||||||
|
while (t < maxT)
|
||||||
|
{
|
||||||
|
t += speed * Time.unscaledDeltaTime;
|
||||||
|
target.localScale = Vector3.one * animCurve.Evaluate(maxT - t);
|
||||||
|
yield return null;
|
||||||
|
}
|
||||||
|
transform.localScale = initScale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 65fce2c84ce1eff4383c094d715a7e1b
|
||||||
|
timeCreated: 1492258094
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue