Hi,
Just found out a this method in AnchorPoint class in UIRect.cs
public Vector3[] GetSides (Transform relativeTo)
{
if (target != null)
{
if (rect != null) return rect.GetSides(relativeTo);
#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6
if (target.camera != null) return target.camera.GetSides(relativeTo);
#else
if (target.GetComponent<Camera>() != null) return target.GetComponent<Camera>().GetSides(relativeTo);
#endif
}
return null;
}
This method cause allocations on every frame and also take couple of milliseconds to execute.
There are two problems here as far as I can tell:
1. Using GetComponent every frame
2. Using GetComponent twice rather that just caching the result
It would be great if this piece of code could be optimized for future releases.
BTW I am using NGUI 3.9.0