Performance update to UILineConnector only draw when child transforms move.
https://bitbucket.org/UnityUIExtensions/unity-ui-extensions/issues/123/uilinerenderer-issues-with-specifyingrelease
parent
11ee80411f
commit
2294f34905
|
@ -11,6 +11,7 @@ namespace UnityEngine.UI.Extensions
|
|||
|
||||
// The elements between which line segments should be drawn
|
||||
public RectTransform[] transforms;
|
||||
private Vector2[] previousPositions;
|
||||
private RectTransform canvas;
|
||||
private RectTransform rt;
|
||||
private UILineRenderer lr;
|
||||
|
@ -29,6 +30,19 @@ namespace UnityEngine.UI.Extensions
|
|||
{
|
||||
return;
|
||||
}
|
||||
//Performance check to only redraw when the child transforms move
|
||||
if (previousPositions != null && previousPositions.Length == transforms.Length)
|
||||
{
|
||||
bool updateLine = false;
|
||||
for (int i = 0; i < transforms.Length; i++)
|
||||
{
|
||||
if (!updateLine && previousPositions[i] != transforms[i].anchoredPosition)
|
||||
{
|
||||
updateLine = true;
|
||||
}
|
||||
}
|
||||
if (!updateLine) return;
|
||||
}
|
||||
|
||||
// Get the pivot points
|
||||
Vector2 thisPivot = rt.pivot;
|
||||
|
@ -61,6 +75,12 @@ namespace UnityEngine.UI.Extensions
|
|||
lr.Points = points;
|
||||
lr.RelativeSize = false;
|
||||
lr.drivenExternally = true;
|
||||
|
||||
previousPositions = new Vector2[transforms.Length];
|
||||
for (int i = 0; i < transforms.Length; i++)
|
||||
{
|
||||
previousPositions[i] = transforms[i].anchoredPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue