ソースコード
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", "カイリュー" );
}
}
}