Skip to content

Instantly share code, notes, and snippets.

@arclee
Last active August 21, 2017 11:51
Show Gist options
  • Save arclee/8c25e8354892a751f2334e92f5d16b18 to your computer and use it in GitHub Desktop.
Save arclee/8c25e8354892a751f2334e92f5d16b18 to your computer and use it in GitHub Desktop.
public void GUIMatrixAutoScale(float fromScreenX, float fromScreenY)
{
Matrix4x4 _matrix = GUI.matrix;
_matrix.m00 = (float)Screen.width / fromScreenX;
_matrix.m11 = (float)Screen.height / fromScreenY;
GUI.matrix = _matrix;
}
void OnGUI()
{
// 你在 Editor 裡的原本看起來畫面大小。
GUIMatrixAutoScale(800.0f, 600.0f);
// GUI 程式寫在下面。
// GUI.XXXX
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment