using UnityEngine;
using System.Collections;

[RequireComponent(typeof(Camera))]
public class FixedWidthCamera : MonoBehaviour
{
    private Camera AttachedCamera;

    public Transform LeftMostPoint;
    public Transform RightMostPoint;
    private float DesiredWidth = 0;

    void Awake()
    {
        AttachedCamera = GetComponent<Camera>();
        DesiredWidth = Vector3.Distance(LeftMostPoint.position, RightMostPoint.position) / 2.0f;
    }

    void Update()
    {
        float AspectRatio = (float)Screen.width / (float)Screen.height;
        AttachedCamera.orthographicSize = DesiredWidth / AspectRatio;
    }
}