Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active December 21, 2015 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/6290261 to your computer and use it in GitHub Desktop.
Save tsubaki/6290261 to your computer and use it in GitHub Desktop.
非ピクセルパーフェクトでOnGUIを表現するサンプル。どの解像度でも800x1280想定でGUIが作られる。
public class NoPixelperfectOnGUI : MonoBehaviour
{
[SerializeField]
Vector2 screenSize = new Vector2(800,1280); // GUI想定解像度
void OnGUI()
{
// GUI用の解像度を更新
GUIUtility.ScaleAroundPivot(new Vector2( Screen.width / screenSize.x, Screen.height / screenSize.y), Vector2.zero);
GUI.Button( new Rect(0, 0, 400, 640), "hoge");
// GUI表現
// GUIを元の解像度に戻す
GUI.matrix = Matrix4x4.identity;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment