Updated LineRenderer and UILIneConnector implementations to both be safer and include warning about placing a UILineRenderer at any other position than 0,0,0.
parent
e7babe0dd6
commit
796f66c310
|
@ -296,8 +296,6 @@ namespace UnityEngine.UI.Extensions
|
||||||
PopulateMesh (vh, pointsToDraw);
|
PopulateMesh (vh, pointsToDraw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private UIVertex[] CreateLineCap(Vector2 start, Vector2 end, SegmentType type)
|
private UIVertex[] CreateLineCap(Vector2 start, Vector2 end, SegmentType type)
|
||||||
|
@ -501,6 +499,10 @@ namespace UnityEngine.UI.Extensions
|
||||||
{
|
{
|
||||||
m_points = new Vector2[1];
|
m_points = new Vector2[1];
|
||||||
}
|
}
|
||||||
|
if (transform.GetComponent<RectTransform>().position != Vector3.zero)
|
||||||
|
{
|
||||||
|
Debug.LogWarning("A Line Renderer component should be on a RectTransform positioned at (0,0,0), do not use in child Objects.\nFor best results, create separate RectTransforms as children of the canvas positioned at (0,0) for a UILineRenderer and do not move.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,10 @@ namespace UnityEngine.UI.Extensions
|
||||||
bool updateLine = false;
|
bool updateLine = false;
|
||||||
for (int i = 0; i < transforms.Length; i++)
|
for (int i = 0; i < transforms.Length; i++)
|
||||||
{
|
{
|
||||||
|
if (transforms[i] == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!updateLine && previousPositions[i] != transforms[i].position)
|
if (!updateLine && previousPositions[i] != transforms[i].position)
|
||||||
{
|
{
|
||||||
updateLine = true;
|
updateLine = true;
|
||||||
|
@ -60,6 +64,10 @@ namespace UnityEngine.UI.Extensions
|
||||||
// First, convert the pivot to worldspace
|
// First, convert the pivot to worldspace
|
||||||
for (int i = 0; i < transforms.Length; i++)
|
for (int i = 0; i < transforms.Length; i++)
|
||||||
{
|
{
|
||||||
|
if (transforms[i] == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
worldSpaces[i] = transforms[i].TransformPoint(thisPivot);
|
worldSpaces[i] = transforms[i].TransformPoint(thisPivot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +91,10 @@ namespace UnityEngine.UI.Extensions
|
||||||
previousPositions = new Vector3[transforms.Length];
|
previousPositions = new Vector3[transforms.Length];
|
||||||
for (int i = 0; i < transforms.Length; i++)
|
for (int i = 0; i < transforms.Length; i++)
|
||||||
{
|
{
|
||||||
|
if (transforms[i] == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
previousPositions[i] = transforms[i].position;
|
previousPositions[i] = transforms[i].position;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue