Skip to content

Instantly share code, notes, and snippets.

@GeorgiyRyaposov
Created October 8, 2020 01:22
Show Gist options
  • Save GeorgiyRyaposov/e75a3cf109d08d89b2b87682b05cb533 to your computer and use it in GitHub Desktop.
Save GeorgiyRyaposov/e75a3cf109d08d89b2b87682b05cb533 to your computer and use it in GitHub Desktop.
private Bounds OrthographicBounds(float orthographicSize)
{
float screenAspect = (float)Screen.width / (float)Screen.height;
float cameraHeight = orthographicSize * 2;
Bounds bounds = new Bounds(
transform.position,
new Vector3(cameraHeight * screenAspect, cameraHeight, 0));
return bounds;
}
private float BoundsToOrthographic(Bounds bounds)
{
float screenAspect = (float)Screen.width / (float)Screen.height;
return bounds.size.x / screenAspect * 0.5f;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment