Skip to content

Instantly share code, notes, and snippets.

@ProjectX1989
Created July 29, 2019 17:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ProjectX1989/f5a728388d97e26b772615ca7c48285e to your computer and use it in GitHub Desktop.
Save ProjectX1989/f5a728388d97e26b772615ca7c48285e to your computer and use it in GitHub Desktop.
public class SetLowRez : MonoBehaviour
{
[SerializeField] protected bool doOnAwake = true;
[SerializeField] protected int xRes = 64, yRes = 64;
private int bigXRes, bigYRes;
private bool isLowRes;
private void SetSmallResolution()
{
isLowRes = true;
bigXRes = Screen.currentResolution.width;
bigYRes = Screen.currentResolution.height;
Screen.SetResolution(xRes, yRes, true);
}
private void SetBigResolution()
{
isLowRes = false;
Screen.SetResolution(bigXRes, bigYRes, true);
}
private void Awake()
{
if (doOnAwake)
{
SetSmallResolution();
}
}
private void Update()
{
if (Input.GetKeyDown(KeyCode.K))
{
if (isLowRes)
{
SetBigResolution();
}
else
{
SetSmallResolution();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment