Created
March 28, 2021 09:39
-
-
Save dyguests/cde6b7b84cd107676932f30dc7c9c251 to your computer and use it in GitHub Desktop.
fill screen.
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
using UnityEngine; | |
namespace Game | |
{ | |
public class FillScreen : MonoBehaviour | |
{ | |
public SpriteRenderer sr; | |
private void Awake() | |
{ | |
var screenRadio = (float) Screen.height / Screen.width; | |
var spriteRadio = sr.size.y / sr.size.x; | |
if (screenRadio > spriteRadio) | |
{ | |
sr.size = screenRadio / spriteRadio * sr.size; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment