Help with underwater fog

I have written code and have done everything correctly at every turn yet my underwater fog fights me every step of the way, I can usually think of something that fixes enough for me to work with the problem more until I can figure it out but I am fresh out of ideas other than restarting completely. I seriously need help with this issue I have no idea why something that should be so simple is fighting me so badly.

I have created a water plane made it look good with my custom water material (default shaders), then made a box sized and positioned it perfectly where i need it, made the box a child of the water plane and attached a script to the box, then made the whole thing a prefab and dragged them onto the scene where i need the,

here is what someone has written to try and help me so far.

[LIST=1]
[*]using UnityEngine;
[*]using System.Collections;
[*]

[*]public class test : MonoBehaviour {
[*]   public Camera camera;
[*]   public Renderer renderer;
[*]

[*]   private bool defaultFog = false;
[*]   private Color defaultFogColor = Color.black;
[*]   private float defaultFogDensity = 0;
[*]

[*]   public Color topFogColor = Color.red;
[*]   public Color bottomFogColor = Color.blue;
[*]   public float fogDensity = 0.075f;
[*]   public float maxColorDepth = 10;
[*]

[*]   // Use this for initialization
[*]   void Start () {
[*]        camera = Camera.main;
[*]       if (camera == null) camera = Camera.allCameras[0];
[*]        defaultFog = RenderSettings.fog;
[*]        defaultFogColor = RenderSettings.fogColor;
[*]        defaultFogDensity = RenderSettings.fogDensity;
[*]        renderer = gameObject.GetComponent<Renderer>();
[*]   }
[*]  
[*]   // Update is called once per frame
[*]   void Update () {
[*]       if (camera == null || renderer == null) return;
[*]

[*]       // test fog according to the bounding box of the water "box")
[*]        SetFog(renderer.bounds.Contains(camera.transform.position));
[*]   }
[*]

[*]   void SetFog(bool underWater)
[*]   {
[*]       if (!underWater) {
[*]           RenderSettings.fog = defaultFog;
[*]           RenderSettings.fogColor = defaultFogColor;
[*]           RenderSettings.fogDensity = defaultFogDensity;
[*]           return;
[*]       }
[*]

[*]       var depthAmount = (renderer.bounds.max.y - camera.transform.position.y) / maxColorDepth;
[*]

[*]       var fogColor = Color.Lerp(topFogColor, bottomFogColor, depthAmount);
[*]

[*]       RenderSettings.fog = true;
[*]       RenderSettings.fogColor = fogColor;
[*]       RenderSettings.fogDensity = fogDensity;
[*]   }
[*]}
[/LIST]

the problem with this code is it only works with one prefab, like the script itself can only work once in the whole scene, I have no idea what is wrong with it and he is better at coding than me so to me it looks pretty flawless but I am not 100% certain since some of it is kind of beyond my skills right now.

*Thanks to bigmisterb for writing this

and here is my code I salvaged a lot from the last script.

using UnityEngine;
using System.Collections;

public class UnderWaterEffect : MonoBehaviour {

    //the water cell that the script will use to determine when under water effects should take place.
    [Header("Water Cell")]
    public Renderer underWaterMarker;

    //the camera that the script will control for under water effects.
    [HideInInspector]
    public Camera cameraToFollow;

    //Variables to keep track of the default fog.
    private bool defaultFog;
    private Color defaultFogColor;
    private float defaultFogDensity;


    //Variables used to determine the underwater effects color and density.
    [Header("Under Water Effect")]
    public Color shallowFogColor = Color.cyan;
    public Color deepFogColor = Color.blue;
    public float fogDensity = 0.075f;

    //Variable that determines the depth the water changes color.
    [Header("Depth Control")]
    public float waterDepth = 10.0f;

    void Start() {
        //Sets the camera to the main camera, if none can be found it attaches it to all cameras.
        cameraToFollow = Camera.main;
        if (cameraToFollow == null) cameraToFollow = Camera.allCameras[0];

        //gets the default fog values.
        defaultFog = RenderSettings.fog;
        defaultFogColor = RenderSettings.fogColor;
        defaultFogDensity = RenderSettings.fogDensity;

        //Gets the attached gameObject if nothing is assigned
        if (underWaterMarker == null) underWaterMarker = gameObject.GetComponent<Renderer>();
    }

    void Update() {
        //Every frame check to see if the player is under water.
        if (underWaterMarker.bounds.Contains(cameraToFollow.transform.position)) {
            waterDepthFog();
        }
        else {
            RenderSettings.fog = defaultFog;
            RenderSettings.fogColor = defaultFogColor;
            RenderSettings.fogDensity = defaultFogDensity;
        }
    }

    void waterDepthFog() {
        var depthAmount = (underWaterMarker.bounds.max.y - cameraToFollow.transform.position.y) / waterDepth;
        var fogColor = Color.Lerp(shallowFogColor, deepFogColor, depthAmount);

        RenderSettings.fog = true;
        RenderSettings.fogColor = fogColor;
        RenderSettings.fogDensity = fogDensity;
    }
}

Mine is probably very bad but it pretty much has the same issue, I only wrote it here because I am making my first game and wanted to write all the scripts by myself, so I used the last one as a guide and sort of made it myself with what I am capable of.