以下の内容はhttps://hacchi-man.hatenablog.com/entry/2020/09/21/220000より取得しました。


【Unity】GUILayoutUtility.GetRect が正しく取得できないことがある

下記コードで RenderTexture を表示させた場合は
下図のように横幅が広がってしまう

// public static Rect GetRect(float minWidth, float maxWidth, float minHeight, float maxHeight);
var rect = GUILayoutUtility.GetRect(
    0,
    _renderTexture.width,
    0,
    _renderTexture.height
);

EditorGUI.DrawTextureTransparent(rect, _renderTexture);

f:id:hacchi_man:20200918210445p:plain

次に GUILayoutOption を 利用してみる

そうすると正しく、表示されます

// public static Rect GetRect(float width, float height, params GUILayoutOption[] options)
var rect = GUILayoutUtility.GetRect(
    0,
    0,
    GUILayout.MaxWidth(_renderTexture.width),
    GUILayout.MaxHeight(_renderTexture.height)
);

f:id:hacchi_man:20200918213507p:plain




以上の内容はhttps://hacchi-man.hatenablog.com/entry/2020/09/21/220000より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14