How can I create a boundary (collider?) that the ship cant leave?

I’m making a simple 2D space shooter, and I’m trying to figure out how to keep the ship from exiting the screen. With the current script, the ship stops from leaving the screen but half of it hangs off the side. I’ve included two images showing it on screen and hanging off the side. Below is the script I’m using. I tried using the mesh renderer to try to keep it on as well, but Im not too sure if I even went in the right direction with it.

//Update the position of the ship based on “Horizontal” and “Vertical” input.
void UpdatePosition () {

	//Trying to call the actual mesh renderer into the script for boundaries. 
	//MeshRenderer = gameObject.GetComponent<MeshRenderer> ();
	
	//Attempt to set the actual bounds around the Mesh renderer rather than the generic numbers. 
	//Bounds newBounds = new Bounds (renderer.bounds.min.x, renderer.bounds.max.x);

	//Move the player vertically on the Y coordinate.
	movement.y = Input.GetAxis ("Vertical") * Time.deltaTime * VerticalMoveSpeed; 
			
	//Move the player laterally in the 'X' coordinate. 
	movement.x = Input.GetAxis ("Horizontal") * Time.deltaTime * HorizontalMoveSpeed;

	//Adding a thruster to the ship. By pressing "T" they will move
	//at an accelerated rate. 
	if (Input.GetKey (KeyCode.T)) {
		//Tells the system how fast the ship should move whie the T buton is being held.		
		movement.y = Input.GetAxis ("Vertical") * Time.deltaTime * ThrustVertMoveSpeed;
		movement.x = Input.GetAxis ("Horizontal") * Time.deltaTime * ThrustHorizMoveSpeed;
		}

	//Apply the movement vector to the game object's position. 
	gameObject.transform.Translate (movement); 

	//Transform the 3D world position to a screen picel location. 
	Vector3 screenPosition = CameraObject.WorldToScreenPoint (gameObject.transform.position); 

	//Off screen to the RIGHT?
	if (screenPosition.x > Screen.width) {
			//Clamp (reset) to the screens right side
			screenPosition.x = Screen.width; 
			//Transform clamped screen position to world space
			//and assign to a player ship. 
			gameObject.transform.position = CameraObject.ScreenToWorldPoint (screenPosition); 
			}

	//Off screen to the LEFT?
	else if (screenPosition.x < 0) {
			//Clamp (Reset) to the screens left side
			screenPosition.x = 0;
			//Transform clamped screen position to world space
			//and assign to a player ship. 
			gameObject.transform.position = CameraObject.ScreenToWorldPoint (screenPosition); 
		}

	//Off screen going DOWN?
	else if (screenPosition.y > Screen.height) {
		//Clamp (reset) to the screens upper section.
		screenPosition.y = Screen.height; 
		//Transform clamped screen position to world space
		//and assign to a player ship. 
		gameObject.transform.position = CameraObject.ScreenToWorldPoint (screenPosition); 
	}
	
	//Off screen to the UP?
	else if (screenPosition.y < 0) {
		//Clamp (Reset) to the screens bottom
		screenPosition.y = 0;
		//Transform clamped screen position to world space
		//and assign to a player ship. 
		gameObject.transform.position = CameraObject.ScreenToWorldPoint (screenPosition); 
	}
	}

33504-shipoffscreen.png

You need to consider the size of the ship when positioning at the edges. For example:

//Off screen to the RIGHT?
if (screenPosition.x > Screen.width) {
  //Clamp (reset) to the screens right side
  screenPosition.x = Screen.width - (shipsWidth / 2);
  //Transform clamped screen position to world space
  //and assign to a player ship.
  gameObject.transform.position = CameraObject.ScreenToWorldPoint (screenPosition);
}

//Off screen going DOWN?
else if (screenPosition.y > Screen.height) {
    //Clamp (reset) to the screens upper section.
    screenPosition.y = Screen.height - (shipsHeight / 2);
    //Transform clamped screen position to world space
    //and assign to a player ship.
    gameObject.transform.position = CameraObject.ScreenToWorldPoint (screenPosition);
}

The same applies for all other edges.