Unity/端末サイズ
提供: 初心者エンジニアの簡易メモ
サンプル
void Awake() { TermSize.orthographicSizeAuto(); }
TermSize.cs
public class TermSize { public static void orthographicSizeAuto () { // 縦画面 iPhone6 float developAspect = 750.0f / 1334.0f; // 横画面 iPhone6 // float developAspect = 1334.0f / 750.0f; float deviceAspect = (float)Screen.width / (float)Screen.height; float scale = deviceAspect / developAspect; Camera mainCamera = Camera.main; float deviceSize = mainCamera.orthographicSize; float deviceScale = 1.0f / scale; if (scale > 1) { Debug.Log("scale変更不要"); return; } mainCamera.orthographicSize = deviceSize * deviceScale; } }