Ejemplo n.º 1
0
 /// <summary>
 /// Called when the camera view target changes on the vehicle camera.
 /// </summary>
 /// <param name="newCameraViewTarget"></param>
 public void OnCameraViewTargetChanged(CameraViewTarget newCameraViewTarget)
 {
     if (newCameraViewTarget != null)
     {
         currentView = newCameraViewTarget.CameraView;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Select a new Vehicle Camera View.
        /// </summary>
        /// <param name="newView">The new camera view.</param>
        public virtual void SetView(VehicleCameraView newView)
        {
            // If no target vehicle, set to null and exit.
            if (targetVehicle == null)
            {
                SetView(null);
                return;
            }

            // Search all camera views on vehicle for desired view
            for (int i = 0; i < targetVehicle.CameraViewTargets.Count; ++i)
            {
                if (targetVehicle.CameraViewTargets[i].CameraView == newView)
                {
                    SetView(targetVehicle.CameraViewTargets[i]);
                    return;
                }
            }

            // If none found, default to the first available
            if (targetVehicle.CameraViewTargets.Count > 0)
            {
                // Set the first available Camera View Target
                SetView(targetVehicle.CameraViewTargets[0]);

                // Issue a warning
                Debug.LogWarning("No CameraViewTarget found for VehicleCameraView " + newView.ToString() + ". Defaulting to " +
                                 selectedCameraViewTarget.CameraView.ToString());
            }
            else
            {
                SetView(null);

                // Issue a warning
                Debug.LogWarning("No CameraViewTarget found on vehicle, vehicle camera will not work. Please add one or more CameraViewTarget components to the vehicle hierarchy.");
            }
        }