void OptimizePagination() { if (Pagination == null) { return; } // a) Ensure that the Pagination object has a 'Canvas' component. // This helps reduce the overhead of adjusting components within the Pagination section var paginationCanvas = Pagination.GetComponent <Canvas>(); if (paginationCanvas == null) { Pagination.AddComponent <Canvas>(); Pagination.AddComponent <UnityEngine.UI.GraphicRaycaster>(); } }