- Home /
 
 
               Question by 
               fahd · Jan 12, 2016 at 09:35 PM · 
                uiscrollmemory managementgarbage collection  
              
 
              Scrollrect loads only the next element
I have lots of elements inside scrollrect is there any event to know if gameobject is inside the viewport
something similar to android listview where it loads only the next element when you reach to it. 
               Comment
              
 
               
              Answer by hulahoolgames · Jan 12, 2016 at 10:26 PM
This might help you. I had colliders on my gameobjects and was testing if they are inside the camera bounds using this code:
 public static bool isInsideCamera(BoxCollider collider) {
         if(m_MainCamera == null) {
             m_MainCamera = Camera.main;
         }
         if(collider == null) {
             Logger.Log("The collider is null : " +collider.gameObject.name);
         }
         // calculate the current camera frustrum planes
         m_CameraPlanes = GeometryUtility.CalculateFrustumPlanes(m_MainCamera);
         bool isInCamera = GeometryUtility.TestPlanesAABB(m_CameraPlanes, collider.bounds);
         return isInCamera;
     }
 
               If your objects dont have colliders, then you can calculate the bounds somehow and send them to the TestPlanesAABB function.
Your answer
 
             Follow this Question
Related Questions
Unity Image Loading System optimization request 1 Answer
Scroll Rect Min/Max Size 0 Answers
[UI] Profiler scroll rect 0 Answers
Where can I edit UI.ScrollView? 0 Answers
Scrolling Scroll Rect with Buttons 4 Answers