Updated LineRenderer and UILIneConnector implementations to both be safer and include warning about placing a UILineRenderer at any other position than 0,0,0.

pull/442/head^2
SimonDarksideJ 2023-06-17 18:33:22 +01:00
parent e7babe0dd6
commit 796f66c310
2 changed files with 16 additions and 2 deletions

View File

@ -296,8 +296,6 @@ namespace UnityEngine.UI.Extensions
PopulateMesh (vh, pointsToDraw);
}
}
}
private UIVertex[] CreateLineCap(Vector2 start, Vector2 end, SegmentType type)
@ -501,6 +499,10 @@ namespace UnityEngine.UI.Extensions
{
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.");
}
}
}
}

View File

@ -40,6 +40,10 @@ namespace UnityEngine.UI.Extensions
bool updateLine = false;
for (int i = 0; i < transforms.Length; i++)
{
if (transforms[i] == null)
{
continue;
}
if (!updateLine && previousPositions[i] != transforms[i].position)
{
updateLine = true;
@ -60,6 +64,10 @@ namespace UnityEngine.UI.Extensions
// First, convert the pivot to worldspace
for (int i = 0; i < transforms.Length; i++)
{
if (transforms[i] == null)
{
continue;
}
worldSpaces[i] = transforms[i].TransformPoint(thisPivot);
}
@ -83,6 +91,10 @@ namespace UnityEngine.UI.Extensions
previousPositions = new Vector3[transforms.Length];
for (int i = 0; i < transforms.Length; i++)
{
if (transforms[i] == null)
{
continue;
}
previousPositions[i] = transforms[i].position;
}
}