Ive been trying to build the following code that comes up with 3 of the same errors “default parameter specifiers are not permitted”.
public static void SetCameraBounds(Camera cam = null) { // error
// If no Camera was passed in, use the main Camera
if (cam == null) cam = Camera.main;
// This makes a couple of important assumptions about the camera!:
// 1. The camera is Orthographic
// 2. The camera is at a rotation of R:[0,0,0]
// Make Vector3s at the topLeft and bottomRight of the Screen coords
Vector3 topLeft = new Vector3( 0, 0, 0 );
Vector3 bottomRight = new Vector3( Screen.width, Screen.height, 0 );
// Convert these to world coordinates
Vector3 boundTLN = cam.ScreenToWorldPoint( topLeft );
Vector3 boundBRF = cam.ScreenToWorldPoint( bottomRight );
// Adjust their zs to be at the near and far Camera clipping planes
boundTLN.z += cam.nearClipPlane;
boundBRF.z += cam.farClipPlane;
// Find the center of the Bounds
Vector3 center = (boundTLN + boundBRF)/2f;
_camBounds = new Bounds( center, Vector3.zero );
// Expand _camBounds to encapsulate the extents.
_camBounds.Encapsulate( boundTLN );
_camBounds.Encapsulate( boundBRF );
}
// Checks to see whether the Bounds bnd are within the camBounds //error
public static Vector3 ScreenBoundsCheck(Bounds bnd, BoundsTest test = BoundsTest.center) {
return( BoundsInBoundsCheck( camBounds, bnd, test ) );
}
// Checks to see whether Bounds lilB are within Bounds bigB //error
public static Vector3 BoundsInBoundsCheck( Bounds bigB, Bounds lilB, BoundsTest test = BoundsTest.onScreen ) {
I’ve already looked at the solution to the problem at Default Parameter Specifiers Are Not Permitted - Unity Answers. The solution says to go change something in the project options, but my project options is grayed out. What do i need to do to fix this?