private void Update()
    {
        var player = Finder.GetPlayer();
        var formationConfiguration = player.GetComponent <FormationConfiguration>();

        var gridWidth  = formationConfiguration.GetSlotDistance().x *formationConfiguration.GetGridSize().X;
        var gridHeight = formationConfiguration.GetSlotDistance().y *formationConfiguration.GetGridSize().Z;

        // divide grid size by two, because of left = -orthographicSize and right = +orthographicSize
        orthographicSize = Mathf.Max(gridHeight / 2.0f, gridWidth / 2.0f);

        var aspect = (Screen.width + 0.0f) / (Screen.height + 0.0f);

        m_perspective = Matrix4x4.Perspective(fov, aspect, near, far);
        m_ortho       = Matrix4x4.Ortho(-orthographicSize * aspect, orthographicSize * aspect, -orthographicSize, orthographicSize, near, far);

        // check if state has changed, update matrix accordingly
        switch (m_nextState)
        {
        case NextSwitcherState.None:
            break;

        case NextSwitcherState.Perspective:
            BlendToMatrix(m_perspective, 1f);
            break;

        case NextSwitcherState.Ortho:
            BlendToMatrix(m_ortho, 1f);
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }

        // after starting co-routine wait until next state change is requested
        m_nextState = NextSwitcherState.None;
    }
 /// <summary>
 /// Tells the camera to switch to orthographic view.
 /// </summary>
 public void SwitchToOrtho()
 {
     m_nextState = NextSwitcherState.Ortho;
 }
 /// <summary>
 /// Tells the camera to switch to perspective view.
 /// </summary>
 public void SwitchToPerspective()
 {
     m_nextState = NextSwitcherState.Perspective;
 }