Slight reorg and addition of the following components:
* Radial layout * Tile Size Fitter * UI Circle Primative * Switch to RectTransform * Input Field Enter Submit (alt to ReturnKeyTrigger)release
parent
cdde18f8d0
commit
64067d97b4
|
@ -866,7 +866,7 @@ namespace UnityEditor.UI
|
|||
SetDefaultColorTransitionValues(slider);
|
||||
}
|
||||
|
||||
[MenuItem("GameObject/UI/Extensions/UI Line Renderer", false)]
|
||||
[MenuItem("GameObject/UI/Extensions/Primatives/UI Line Renderer", false)]
|
||||
static public void AddUILineRenderer(MenuCommand menuCommand)
|
||||
{
|
||||
GameObject go = CreateUIElementRoot("UI LineRenderer", menuCommand, s_ImageGUIElementSize);
|
||||
|
@ -874,7 +874,7 @@ namespace UnityEditor.UI
|
|||
Selection.activeGameObject = go;
|
||||
}
|
||||
|
||||
[MenuItem("GameObject/UI/Extensions/UI Line Texture Renderer", false)]
|
||||
[MenuItem("GameObject/UI/Extensions/Primatives/UI Line Texture Renderer", false)]
|
||||
static public void AddUILineTextureRenderer(MenuCommand menuCommand)
|
||||
{
|
||||
GameObject go = CreateUIElementRoot("UI LineTextureRenderer", menuCommand, s_ImageGUIElementSize);
|
||||
|
@ -882,6 +882,14 @@ namespace UnityEditor.UI
|
|||
Selection.activeGameObject = go;
|
||||
}
|
||||
|
||||
[MenuItem("GameObject/UI/Extensions/Primatives/UI Circle", false)]
|
||||
static public void AddUICircle(MenuCommand menuCommand)
|
||||
{
|
||||
GameObject go = CreateUIElementRoot("UI Circle", menuCommand, s_ImageGUIElementSize);
|
||||
go.AddComponent<UICircle>();
|
||||
Selection.activeGameObject = go;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helper Functions
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
/// Usage: Add this component to the input and add the
|
||||
/// function to execute to the EnterSubmit event of this script
|
||||
/// Credit Vicente Russo
|
||||
/// Sourced from - https://bitbucket.org/ddreaper/unity-ui-extensions/issues/23/returnkeytriggersbutton
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Usage: Add this component to the input and add the function to execute to the EnterSubmit event of this script
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(InputField))]
|
||||
[AddComponentMenu("UI/Extensions/Input Field Submit")]
|
||||
public class InputFieldEnterSubmit : MonoBehaviour
|
||||
{
|
||||
|
||||
|
@ -28,3 +32,4 @@ public class InputFieldEnterSubmit : MonoBehaviour
|
|||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bfc77d7b04a86f845b59fb0979e8ec53
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
|
@ -0,0 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 759c961dc0e85a348ab9cd1278319ca0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
|
@ -1,7 +1,8 @@
|
|||
/// Credit Simie
|
||||
/// Sourced from - http://forum.unity3d.com/threads/flowlayoutgroup.296709/
|
||||
/// Example http://forum.unity3d.com/threads/flowlayoutgroup.296709/
|
||||
|
||||
/// Update by Martin Sharkbomb - http://forum.unity3d.com/threads/flowlayoutgroup.296709/#post-1977028
|
||||
/// Last item alignment fix by Vicente Russo - https://bitbucket.org/ddreaper/unity-ui-extensions/issues/22/flow-layout-group-align
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
@ -13,7 +14,9 @@ namespace UnityEngine.UI.Extensions
|
|||
[AddComponentMenu("Layout/Extensions/Flow Layout Group")]
|
||||
public class FlowLayoutGroup : LayoutGroup
|
||||
{
|
||||
public float Spacing = 0f;
|
||||
public float SpacingX = 0f;
|
||||
public float SpacingY = 0f;
|
||||
public bool ExpandHorizontalSpacing = false;
|
||||
|
||||
public bool ChildForceExpandWidth = false;
|
||||
public bool ChildForceExpandHeight = false;
|
||||
|
@ -116,14 +119,14 @@ namespace UnityEngine.UI.Extensions
|
|||
var childWidth = LayoutUtility.GetPreferredSize(child, 0);
|
||||
var childHeight = LayoutUtility.GetPreferredSize(child, 1);
|
||||
|
||||
// Max child width is layout group with - padding
|
||||
// Max child width is layout group width - padding
|
||||
childWidth = Mathf.Min(childWidth, workingWidth);
|
||||
|
||||
// If adding this element would exceed the bounds of the row,
|
||||
// go to a new line after processing the current row
|
||||
if (currentRowWidth + childWidth > workingWidth) {
|
||||
|
||||
currentRowWidth -= Spacing;
|
||||
currentRowWidth -= SpacingX;
|
||||
|
||||
// Process current row elements positioning
|
||||
if (!layoutInput) {
|
||||
|
@ -138,7 +141,7 @@ namespace UnityEngine.UI.Extensions
|
|||
|
||||
// Add the current row height to total height accumulator, and reset to 0 for the next row
|
||||
yOffset += currentRowHeight;
|
||||
yOffset += Spacing;
|
||||
yOffset += SpacingY;
|
||||
|
||||
currentRowHeight = 0;
|
||||
currentRowWidth = 0;
|
||||
|
@ -153,12 +156,14 @@ namespace UnityEngine.UI.Extensions
|
|||
currentRowHeight = childHeight;
|
||||
}
|
||||
|
||||
currentRowWidth += Spacing;
|
||||
// Don't do this for the last one
|
||||
if (i < rectChildren.Count - 1 )
|
||||
currentRowWidth += SpacingX;
|
||||
}
|
||||
|
||||
if (!layoutInput) {
|
||||
var h = CalculateRowVerticalOffset(groupHeight, yOffset, currentRowHeight);
|
||||
currentRowWidth -= Spacing;
|
||||
currentRowWidth -= SpacingX;
|
||||
// Layout the final row
|
||||
LayoutRow(_rowList, currentRowWidth, currentRowHeight, workingWidth, padding.left, h, axis);
|
||||
}
|
||||
|
@ -203,10 +208,20 @@ namespace UnityEngine.UI.Extensions
|
|||
xPos += (maxWidth - rowWidth);
|
||||
|
||||
var extraWidth = 0f;
|
||||
var extraSpacing = 0f;
|
||||
|
||||
if (ChildForceExpandWidth) {
|
||||
extraWidth = (maxWidth - rowWidth)/_rowList.Count;
|
||||
}
|
||||
else if (ExpandHorizontalSpacing) {
|
||||
extraSpacing = (maxWidth - rowWidth)/(_rowList.Count - 1);
|
||||
if (_rowList.Count > 1) {
|
||||
if (IsCenterAlign)
|
||||
xPos -= extraSpacing * 0.5f * (_rowList.Count - 1);
|
||||
else if (IsRightAlign)
|
||||
xPos -= extraSpacing * (_rowList.Count - 1);
|
||||
}
|
||||
}
|
||||
|
||||
for (var j = 0; j < _rowList.Count; j++) {
|
||||
|
||||
|
@ -229,12 +244,18 @@ namespace UnityEngine.UI.Extensions
|
|||
else if (IsLowerAlign)
|
||||
yPos += (rowHeight - rowChildHeight);
|
||||
|
||||
//
|
||||
if (ExpandHorizontalSpacing && j > 0)
|
||||
xPos += extraSpacing;
|
||||
|
||||
if (axis == 0)
|
||||
SetChildAlongAxis(rowChild, 0, xPos, rowChildWidth);
|
||||
else
|
||||
SetChildAlongAxis(rowChild, 1, yPos, rowChildHeight);
|
||||
|
||||
xPos += rowChildWidth + Spacing;
|
||||
// Don't do horizontal spacing for the last one
|
||||
if (j < _rowList.Count - 1 )
|
||||
xPos += rowChildWidth + SpacingX;
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ using UnityEngine.EventSystems;
|
|||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[RequireComponent(typeof(ScrollRect))]
|
||||
[AddComponentMenu("UI/Extensions/Horizontal Scroll Snap")]
|
||||
[AddComponentMenu("Layout/Extensions/Horizontal Scroll Snap")]
|
||||
public class HorizontalScrollSnap : MonoBehaviour, IBeginDragHandler, IEndDragHandler, IDragHandler
|
||||
{
|
||||
private Transform _screensContainer;
|
|
@ -0,0 +1,81 @@
|
|||
|
||||
/// Credit ??
|
||||
/// Sourced from - http://www.justapixel.co.uk/radial-layouts-nice-and-simple-in-unity3ds-ui-system/
|
||||
/// Updated by ddreaper - removed dependency on a custom ScrollRect script. Now implements drag interfaces and standard Scroll Rect.
|
||||
|
||||
/*
|
||||
Radial Layout Group by Just a Pixel (Danny Goodayle) - http://www.justapixel.co.uk
|
||||
Copyright (c) 2015
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[AddComponentMenu("Layout/Extensions/Radial Layout")]
|
||||
public class RadialLayout : LayoutGroup {
|
||||
public float fDistance;
|
||||
[Range(0f,360f)]
|
||||
public float MinAngle, MaxAngle, StartAngle;
|
||||
protected override void OnEnable() { base.OnEnable(); CalculateRadial(); }
|
||||
public override void SetLayoutHorizontal()
|
||||
{
|
||||
}
|
||||
public override void SetLayoutVertical()
|
||||
{
|
||||
}
|
||||
public override void CalculateLayoutInputVertical()
|
||||
{
|
||||
CalculateRadial();
|
||||
}
|
||||
public override void CalculateLayoutInputHorizontal()
|
||||
{
|
||||
CalculateRadial();
|
||||
}
|
||||
protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
CalculateRadial();
|
||||
}
|
||||
void CalculateRadial()
|
||||
{
|
||||
m_Tracker.Clear();
|
||||
if (transform.childCount == 0)
|
||||
return;
|
||||
float fOffsetAngle = ((MaxAngle - MinAngle)) / (transform.childCount -1);
|
||||
|
||||
float fAngle = StartAngle;
|
||||
for (int i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
RectTransform child = (RectTransform)transform.GetChild(i);
|
||||
if (child != null)
|
||||
{
|
||||
//Adding the elements to the tracker stops the user from modifiying their positions via the editor.
|
||||
m_Tracker.Add(this, child,
|
||||
DrivenTransformProperties.Anchors |
|
||||
DrivenTransformProperties.AnchoredPosition |
|
||||
DrivenTransformProperties.Pivot);
|
||||
Vector3 vPos = new Vector3(Mathf.Cos(fAngle * Mathf.Deg2Rad), Mathf.Sin(fAngle * Mathf.Deg2Rad), 0);
|
||||
child.localPosition = vPos * fDistance;
|
||||
//Force objects to be center aligned, this can be changed however I'd suggest you keep all of the objects with the same anchor points.
|
||||
child.anchorMin = child.anchorMax = child.pivot = new Vector2(0.5f, 0.5f);
|
||||
fAngle += fOffsetAngle;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1ebce7906e5d20a4fb26d8b510b81926
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
|
@ -0,0 +1,104 @@
|
|||
/// Credit ??
|
||||
/// Sourced from - http://forum.unity3d.com/threads/scripts-useful-4-6-scripts-collection.264161/page-3#post-2280109
|
||||
|
||||
using System.Collections;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(RectTransform))]
|
||||
[AddComponentMenu("Layout/Extensions/Tile Size Fitter")]
|
||||
public class TileSizeFitter : UIBehaviour, ILayoutSelfController
|
||||
{
|
||||
[SerializeField] private Vector2 m_Border = Vector2.zero;
|
||||
public Vector2 Border { get { return m_Border; } set { if (SetPropertyUtility.SetStruct(ref m_Border, value)) SetDirty(); } }
|
||||
|
||||
[SerializeField] private Vector2 m_TileSize = Vector2.zero;
|
||||
public Vector2 TileSize { get { return m_TileSize; } set { if (SetPropertyUtility.SetStruct(ref m_TileSize, value)) SetDirty(); } }
|
||||
|
||||
[System.NonSerialized] private RectTransform m_Rect;
|
||||
private RectTransform rectTransform { get { if (m_Rect == null) m_Rect = GetComponent<RectTransform>(); return m_Rect; } }
|
||||
|
||||
private DrivenRectTransformTracker m_Tracker;
|
||||
|
||||
#region Unity Lifetime calls
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
SetDirty();
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
m_Tracker.Clear();
|
||||
LayoutRebuilder.MarkLayoutForRebuild(rectTransform);
|
||||
base.OnDisable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected override void OnRectTransformDimensionsChange()
|
||||
{
|
||||
UpdateRect();
|
||||
}
|
||||
|
||||
private void UpdateRect()
|
||||
{
|
||||
if (!IsActive())
|
||||
return;
|
||||
|
||||
m_Tracker.Clear();
|
||||
|
||||
m_Tracker.Add(this, rectTransform,
|
||||
DrivenTransformProperties.Anchors |
|
||||
DrivenTransformProperties.AnchoredPosition);
|
||||
rectTransform.anchorMin = Vector2.zero;
|
||||
rectTransform.anchorMax = Vector2.one;
|
||||
rectTransform.anchoredPosition = Vector2.zero;
|
||||
|
||||
m_Tracker.Add(this, rectTransform,
|
||||
DrivenTransformProperties.SizeDeltaX |
|
||||
DrivenTransformProperties.SizeDeltaY);
|
||||
Vector2 sizeDelta = GetParentSize() - Border;
|
||||
if (TileSize.x > 0.001f)
|
||||
sizeDelta.x -= Mathf.Floor(sizeDelta.x / TileSize.x) * TileSize.x;
|
||||
else
|
||||
sizeDelta.x = 0;
|
||||
if (TileSize.y > 0.001f)
|
||||
sizeDelta.y -= Mathf.Floor(sizeDelta.y / TileSize.y) * TileSize.y;
|
||||
else
|
||||
sizeDelta.y = 0;
|
||||
rectTransform.sizeDelta = -sizeDelta;
|
||||
}
|
||||
|
||||
private Vector2 GetParentSize()
|
||||
{
|
||||
RectTransform parent = rectTransform.parent as RectTransform;
|
||||
if (!parent)
|
||||
return Vector2.zero;
|
||||
return parent.rect.size;
|
||||
}
|
||||
|
||||
public virtual void SetLayoutHorizontal() { }
|
||||
public virtual void SetLayoutVertical() { }
|
||||
|
||||
protected void SetDirty()
|
||||
{
|
||||
if (!IsActive())
|
||||
return;
|
||||
|
||||
UpdateRect();
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
protected override void OnValidate()
|
||||
{
|
||||
m_TileSize.x = Mathf.Clamp(m_TileSize.x, 0.001f, 1000f);
|
||||
m_TileSize.y = Mathf.Clamp(m_TileSize.y, 0.001f, 1000f);
|
||||
SetDirty();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 614c629b8dffdb548b9bef9189606bb9
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
|
@ -8,7 +8,7 @@ using UnityEngine.EventSystems;
|
|||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[RequireComponent(typeof(ScrollRect))]
|
||||
[AddComponentMenu("UI/Extensions/Vertical Scroll Snap")]
|
||||
[AddComponentMenu("Layout/Extensions/Vertical Scroll Snap")]
|
||||
public class VerticalScrollSnap : MonoBehaviour, IBeginDragHandler, IEndDragHandler, IDragHandler
|
||||
{
|
||||
private Transform _screensContainer;
|
|
@ -0,0 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ce526e6e0c6202e4e9c5ee35dd79295d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
|
@ -0,0 +1,121 @@
|
|||
/// Credit ??
|
||||
/// Sourced from - http://forum.unity3d.com/threads/draw-circles-or-primitives-on-the-new-ui-canvas.272488/#post-2293224
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[AddComponentMenu("UI/Extensions/Primatives/UI Circle")]
|
||||
public class UICircle : Graphic
|
||||
{
|
||||
[SerializeField]
|
||||
Texture m_Texture;
|
||||
[Range(0, 100)]
|
||||
public int fillPercent = 100;
|
||||
public bool fill = true;
|
||||
public float thickness = 5;
|
||||
[Range(0, 360)]
|
||||
public int segments = 360;
|
||||
|
||||
public override Texture mainTexture
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Texture == null ? s_WhiteTexture : m_Texture;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Texture to be used.
|
||||
/// </summary>
|
||||
public Texture texture
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Texture;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_Texture == value)
|
||||
return;
|
||||
|
||||
m_Texture = value;
|
||||
SetVerticesDirty();
|
||||
SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
|
||||
protected void SetVbo(List<UIVertex> vbo, Vector2[] vertices, Vector2[] uvs)
|
||||
{
|
||||
for (int i = 0; i < vertices.Length; i++)
|
||||
{
|
||||
var vert = UIVertex.simpleVert;
|
||||
vert.color = color;
|
||||
vert.position = vertices[i];
|
||||
vert.uv0 = uvs[i];
|
||||
vbo.Add(vert);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected override void OnFillVBO(List<UIVertex> vbo)
|
||||
{
|
||||
float outer = -rectTransform.pivot.x * rectTransform.rect.width;
|
||||
float inner = -rectTransform.pivot.x * rectTransform.rect.width + this.thickness;
|
||||
|
||||
vbo.Clear();
|
||||
|
||||
Vector2 prevX = Vector2.zero;
|
||||
Vector2 prevY = Vector2.zero;
|
||||
Vector2 uv0 = new Vector2(0, 0);
|
||||
Vector2 uv1 = new Vector2(0, 1);
|
||||
Vector2 uv2 = new Vector2(1, 1);
|
||||
Vector2 uv3 = new Vector2(1, 0);
|
||||
Vector2 pos0;
|
||||
Vector2 pos1;
|
||||
Vector2 pos2;
|
||||
Vector2 pos3;
|
||||
|
||||
float f = (this.fillPercent / 100f);
|
||||
float degrees = 360f / segments;
|
||||
int fa = (int)((segments + 1) * f);
|
||||
|
||||
|
||||
for (int i = 0; i < fa; i++)
|
||||
{
|
||||
float rad = Mathf.Deg2Rad * (i * degrees);
|
||||
float c = Mathf.Cos(rad);
|
||||
float s = Mathf.Sin(rad);
|
||||
|
||||
uv0 = new Vector2(0, 1);
|
||||
uv1 = new Vector2(1, 1);
|
||||
uv2 = new Vector2(1, 0);
|
||||
uv3 = new Vector2(0, 0);
|
||||
|
||||
pos0 = prevX;
|
||||
pos1 = new Vector2(outer * c, outer * s);
|
||||
|
||||
if (fill)
|
||||
{
|
||||
pos2 = Vector2.zero;
|
||||
pos3 = Vector2.zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos2 = new Vector2(inner * c, inner * s);
|
||||
pos3 = prevY;
|
||||
}
|
||||
|
||||
prevX = pos1;
|
||||
prevY = pos2;
|
||||
|
||||
SetVbo(vbo, new[] { pos0, pos1, pos2, pos3 }, new[] { uv0, uv1, uv2, uv3 });
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8185cad1aa202d04ebb9e14ffa533a87
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
|
@ -5,7 +5,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[AddComponentMenu("UI/Extensions/UILineRenderer")]
|
||||
[AddComponentMenu("UI/Extensions/Primatives/UILineRenderer")]
|
||||
public class UILineRenderer : MaskableGraphic
|
||||
{
|
||||
[SerializeField]
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[AddComponentMenu("UI/Extensions/UILineTextureRenderer")]
|
||||
[AddComponentMenu("UI/Extensions/Primatives/UILineTextureRenderer")]
|
||||
public class UILineTextureRenderer : MaskableGraphic
|
||||
{
|
||||
[SerializeField]
|
|
@ -0,0 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8ed31929d883df147b53ffeddcb4f25c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
|
@ -0,0 +1,24 @@
|
|||
/// Credit ??
|
||||
/// Sourced from - http://forum.unity3d.com/threads/find-anchoredposition-of-a-recttransform-relative-to-another-recttransform.330560/#post-2300992
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
|
||||
public static class RectTransformExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts the anchoredPosition of the first RectTransform to the second RectTransform,
|
||||
/// taking into consideration offset, anchors and pivot, and returns the new anchoredPosition
|
||||
/// </summary>
|
||||
public static Vector2 switchToRectTransform(this RectTransform from, RectTransform to)
|
||||
{
|
||||
Vector2 localPoint;
|
||||
Vector2 fromPivotDerivedOffset = new Vector2(from.rect.width * from.pivot.x + from.rect.xMin, from.rect.height * from.pivot.y + from.rect.yMin);
|
||||
Vector2 screenP = RectTransformUtility.WorldToScreenPoint(null, from.position);
|
||||
screenP += fromPivotDerivedOffset;
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(to, screenP, null, out localPoint);
|
||||
Vector2 pivotDerivedOffset = new Vector2(to.rect.width * to.pivot.x + to.rect.xMin, to.rect.height * to.pivot.y + to.rect.yMin);
|
||||
return to.anchoredPosition + localPoint - pivotDerivedOffset;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 977482c1b88728145ba612c0fdec3b92
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"name": "Unity UI Extensions",
|
||||
"version": "1.0.4",
|
||||
"description": "An extension project for the Unity3D UI system, all crafted and contributed by the awesome Unity community",
|
||||
"author": "Simon darkside Jackson <@SimonDarksideJ>",
|
||||
"contributors": [{
|
||||
"name": "Foo Bar",
|
||||
"email": "foo.bar@example.com"
|
||||
}],
|
||||
"repository": {
|
||||
"type": "hg",
|
||||
"url": "https://ddreaper@bitbucket.org/ddreaper/unity-ui-extensions"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://bitbucket.org/ddreaper/unity-ui-extensions/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"nodejitsu",
|
||||
"example",
|
||||
"browsenpm"
|
||||
],
|
||||
"license": "MIT"
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1dbb3faeb54e2a4498b2472b8760548b
|
||||
TextScriptImporter:
|
||||
userData:
|
Loading…
Reference in New Issue