Last active
February 13, 2020 15:54
-
-
Save utoxin/9ce26afd0b90fc2fd9d7c3c18ba4ce3b to your computer and use it in GitHub Desktop.
Sets the Orthographic Size of the main camera to make sure that the play area stays in view. The min vertical and horizontal units are relative to the center of the screen, the same as the Orthographic Size value.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OrthoAspectFixer : MonoBehavior { | |
private Camera _mainCamera; | |
public int minVerticalUnits; | |
public int minHorizontalUnits; | |
void Start() { | |
this._mainCamera = Camera.main; | |
} | |
void Update() { | |
this._mainCamera.orthographicSize = Math.Max(this.minVerticalUnits, this.minHorizontalUnits / this._mainCamera.aspect); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OrthoAspectFixer : MonoBehavior { | |
public int minVerticalUnits; | |
public int minHorizontalUnits; | |
void Start() { | |
var mainCamera = Camera.main; | |
mainCamera.orthographicSize = Math.Max(this.minVerticalUnits, this.minHorizontalUnits / mainCamera.aspect); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment