Code That Is Scene Dependent

I have this script that changes cameras based on the player position.
I was wondering how I could make this so the functionality could change depending on the scene I’m in.

For example:

In scene 1, the camera changes if the player crosses Z=50, Y=20.

In scene 2, the camera changes only if the player crosses X=5.

I was thinking a separate script that would return a function that is either true or false, so I could just keep the script I have but just change the if statements. This is in C# mind you.

This is just an example snippet of code.

 // Update is called once per frame
	void Update () {
		zPosition = playerCamera.transform.position.z;
		
		if (zPosition > 0)
		{
			mainCamera.camera.active = false;
			cam2.camera.active = true;
		}
        if(zPosition < 0)
        {
                   cam2.camera.active = false;
                   mainCamera.camera.active = true;
         }
                       }

I think you want something like this:

if(Application.loadedLevel == 1)
{
//Camera 1 Stuff
}

if(Application.loadedLevel == 2)
{
//Camera 2 Stuff
}

Remember that the scenes must be added to the Build Settings