/// <summary>
        ///     Finds the cameras.
        /// </summary>
        private static void FindCameras(bool sceneViewCameras)
        {
            CameraUtils.GetAllCameras(ref s_Cameras, sceneViewCameras);
            Array.Resize(ref s_CameraNames, s_Cameras.Length);

            for (int index = 0; index < s_Cameras.Length; index++)
            {
                s_CameraNames[index] = new GUIContent(s_Cameras[index].name);
            }
        }
Esempio n. 2
0
        /// <summary>
        ///     Creates a bounding rect that is visible to all cameras.
        /// </summary>
        /// <returns>The culling bounds.</returns>
        public static Bounds CameraCullingBounds()
        {
            CameraUtils.GetAllCameras(ref s_Cameras);
            Array.Resize(ref s_CameraBounds, s_Cameras.Length);

            for (int index = 0; index < s_Cameras.Length; index++)
            {
                Camera camera = s_Cameras[index];

                // boundsTarget is the center of the camera's frustum, in world coordinates:
                Vector3 camPosition    = camera.transform.position;
                Vector3 normCamForward = Vector3.Normalize(camera.transform.forward);
                float   boundsDistance = (camera.farClipPlane - camera.nearClipPlane) / 2.0f + camera.nearClipPlane;
                Vector3 boundsTarget   = camPosition + (normCamForward * boundsDistance);

                s_CameraBounds[index] = new Bounds(boundsTarget, Vector3.zero);
            }

            return(BoundsUtils.CombineBounds(s_CameraBounds));
        }