以下の内容はhttps://baba-s.hatenablog.com/entry/2020/09/29/080100より取得しました。


【Unity】EditorGUIUtility.labelWidth の設定範囲を using で指定できるクラス

ソースコード

using System;
using UnityEditor;

public sealed class LabelWidthScope : IDisposable
{
    private readonly float m_oldLabelWidth;

    public LabelWidthScope( int labelWidth )
    {
        m_oldLabelWidth = EditorGUIUtility.labelWidth;
        EditorGUIUtility.labelWidth = labelWidth;
    }

    public void Dispose()
    {
        EditorGUIUtility.labelWidth = m_oldLabelWidth;
    }
}

使用例

using UnityEditor;

public sealed class Example : EditorWindow
{
    [MenuItem( "Tools/Hoge" )]
    private static void Open()
    {
        GetWindow<Example>();
    }

    private void OnGUI()
    {
        EditorGUILayout.TextField( "Name", "ピカチュウ" );

        using ( new LabelWidthScope( 32 ) )
        {
            EditorGUILayout.TextField( "Name", "カイリュー" );
        }
    }
}

f:id:baba_s:20200825220621p:plain




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

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