Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - yelmam

Pages: [1]
1
NGUI 3 Support / AnchorPoint performance
« on: November 13, 2015, 08:31:19 AM »
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

Pages: [1]