Unity3D: Making a plane fill the camera

I recently had a need in my development to make a plane fit the screen perfectly no matter what the resolution and aspect ratio of the device using an orthographic camera.

Turns out it isn’t too hard using C# you just need this line:

transform.localScale = new Vector3(Camera.main.orthographicSize * 2.0f* Screen.width / Screen.height, Camera.main.orthographicSize * 2.0f, 0.1f);

All you have to do is attach it to the plane you want to scale assuming your camera is the main one in the scene.