目次
環境
- Unity 2022.3
概要
- Editor拡張で使えるUI機能はクラスが4つある
- GUI、GUILayout はUnityEngine名前空間なので、Editor以外でも動作する
- EditorGUI、EditorGUILayout はUnityEditor名前空間なので、Editorでのみ動作する
- Layoutなしは、RectでPositionを指定する必要がある
- ex) Label の最少パラメータのシグネチャー
GUI.Label (Rect position, string text);GUILayout.Label (string text, params GUILayoutOption[] options);
- ex) Label の最少パラメータのシグネチャー
- Layoutありは、Unityが自動レイアウトを行う
- Layoutありなしは、レイアウト関連の関数に違いがあるがUIパーツ周りは対で存在する
- EditorGUI、EditorGUILayout は、GUI、GUILayout よりUIパーツが多く、自由度が高い
- ex) Toggle はGUI、GUILayout はテキストやイメージのパラメータを省略できないが、EditorGUI、EditorGUILayout はチェックボックス単体で描画できる
GUILayout.Toggle (bool value, string text, params GUILayoutOption[] options);EditorGUILayout.Toggle (bool value, params GUILayoutOption[] options);
ex) indentLevel はEditorGUIにしか存在せず、GUI、GUILayoutのUIパーツには効果がない
EditorGUI.indentLevel++; GUILayout.Label("GUILayout"); EditorGUILayout.LabelField("EditorGUILayout");
- ex) Toggle はGUI、GUILayout はテキストやイメージのパラメータを省略できないが、EditorGUI、EditorGUILayout はチェックボックス単体で描画できる
関数一覧
4つのクラスの関数を列挙する。* がついているものはLayoutありなしで同名のメソッドが対で存在するもの。
GUI
| BeginGroup | グループを開始します。これは最後に EndGroup を呼び出す必要があります |
| * BeginScrollView | スクロールビューを開始します |
| * Box | Create a Box on the GUI Layer. |
| BringWindowToBack | 特定のウィンドウを他のフローティングウィンドウの背面に移動させます |
| BringWindowToFront | 特定のウィンドウを他のフローティングウィンドウの前面に移動させます |
| * Button | ボタン。ユーザーがボタンをクリックするとすぐに何かが起こります |
| DragWindow | ウィンドウをドラッグ可能にします |
| DrawTexture | Rect 内部にテクスチャを描画します |
| DrawTextureWithTexCoords | Draw a texture within a rectangle with the given texture coordinates. |
| EndGroup | グループを終了します |
| * EndScrollView | BeginScrollView で開始されたスクロールビューを終了します |
| FocusControl | コントロール名でキーボードのフォーカスを移動させます |
| FocusWindow | ウィンドウをアクティブにします |
| GetNameOfFocusedControl | フォーカスを持つコントロールの名前を取得します |
| * HorizontalScrollbar | 水平のスクロールバー。スクロールバーは文章をスクロールするのに使用します。ほとんどの場合は代わりにスクロールビューを使用してください。 |
| * HorizontalSlider | ユーザーが最小値と最大値の間で値をドラッグで変更できる水平スライダー |
| * Label | スクリーン上のテキストやテクスチャのラベルを作成します |
| ModalWindow | モーダルウィンドウを表示します |
| * PasswordField | パスワードを入力するフィールドを作成します。 |
| * RepeatButton | ユーザーがボタンを押し続けている限り true を返すボタン |
| ScrollTo | スクロールビューに囲まれている中で position の位置を表示するようにスクロールします |
| * SelectionGrid | 選択グリッドボタン |
| SetNextControlName | 次のコントロールに設定する名前 |
| * TextArea | ユーザーが文字列を編集することができる複数行のテキストエリア |
| * TextField | ユーザーが文字列を編集することができるテキストエリア |
| * Toggle | on/off のトグルボタン |
| * Toolbar | ツールバー |
| UnfocusWindow | ウィンドウのフォーカスを外します |
| * VerticalScrollbar | 垂直のスクロールバー。スクロールバーは文章をスクロールするのに使用します。ほとんどの場合は代わりにスクロールビューを使用してください。 |
| * VerticalSlider | ユーザーが最小値と最大値の間で値をドラッグで変更できる垂直スライダー |
| * Window | ポップアップウィンドウ |
GUILayout
| BeginArea | 固定されたスクリーン領域に GUI コントロールの GUILayout ブロックを開始します |
| BeginHorizontal | 水平のコントロールグループを開始します |
| * BeginScrollView | 自動的にレイアウトされるスクロールビューを開始します |
| BeginVertical | 水平のコントロールグループを開始します |
| * Box | 自動レイアウトのボックスを作成します |
| * Button | Make a single press button. |
| EndArea | BeginArea で開始した GUILayout ブロックを閉じます |
| EndHorizontal | BeginHorizontal で開始したグループを閉じます |
| * EndScrollView | BeginScrollView を呼び出して開始したスクロールビューを閉じます |
| EndVertical | BeginVertical で開始したグループを閉じます |
| ExpandHeight | コントロールの垂直方向の拡張を許可/禁止するオプション |
| ExpandWidth | コントロールの水平方向の拡張を許可/禁止するオプション |
| FlexibleSpace | フレキシブルなスペースを挿入します |
| Height | 決められた高さをコントロールに与えるオプション |
| * HorizontalScrollbar | 水平のスクロールバー |
| * HorizontalSlider | ユーザーが最小値と最大値の間で値をドラッグで変更できる水平スライダー |
| * Label | 自動レイアウトのラベル |
| MaxHeight | コントロールの高さの最大値を設定するオプション |
| MaxWidth | コントロールの幅の最大値を設定するオプション |
| MinHeight | コントロールの高さの最小値を設定するオプション |
| MinWidth | Option passed to a control to specify a minimum width. |
| * PasswordField | パスワードを入力するフィールドを作成します。 |
| * RepeatButton | リピートボタン。ユーザーがボタンをマウスで押している間は true を返します。 |
| * SelectionGrid | 選択グリッドボタン |
| Space | 現在のレイアウトグループにスペースを挿入します |
| * TextArea | ユーザーが文字列を編集することができる複数行のテキストエリア |
| * TextField | ユーザーが文字列を編集することができるテキストエリア |
| * Toggle | on/off のトグルボタン |
| * Toolbar | ツールバー |
| * VerticalScrollbar | 垂直のスクロールバー |
| * VerticalSlider | ユーザーが最小値と最大値の間で値をドラッグで変更できる垂直スライダー |
| Width | 決められた幅をコントロールに与えるオプション |
| * Window | ウィンドウ内のコンテンツが自動でレイアウトされるポップアップウィンドウ |
EditorGUI
| BeginChangeCheck | Starts a new code block to check for GUI changes. |
| BeginDisabledGroup | BeginDisabledGroup と EndDisabledGroup で囲んだ GUI グループ内の GUI 要素を操作不可にする場合に使用されます。 |
| * BeginFoldoutHeaderGroup | それの左側に折り畳み矢印でラベルを作成します。 |
| BeginProperty | SerializedPropertyを GUI で管理しやすくするようにするためのプロパティーのラッパーである GUI グループを作成します |
| * BoundsField | Makes Center and Extents field for entering a Bounds. |
| * BoundsIntField | Makes Position and Size field for entering a BoundsInt. |
| CanCacheInspectorGUI | Get whether a SerializedProperty's inspector GUI can be cached. |
| * ColorField | Makes a field for selecting a Color. |
| * CurveField | Makes a field for editing an AnimationCurve. |
| * DelayedDoubleField | Makes a delayed text field for entering doubles. |
| * DelayedFloatField | Makes a delayed text field for entering floats. |
| * DelayedIntField | Makes a delayed text field for entering integers. |
| * DelayedTextField | Makes a delayed text field. |
| * DoubleField | Makes a text field for entering doubles. |
| DrawPreviewTexture | 矩形内にテクスチャを描画します。 |
| DrawRect | 現在の Editor Window 内の指定された位置とサイズに色で塗りつぶした矩形を描画します。 |
| DrawTextureAlpha | 矩形内のテクスチャのアルファチャネルを描画します。 |
| * DropdownButton | Makes a button that reacts to mouse down, for displaying your own dropdown content. |
| DropShadowLabel | ドロップシャドウ付きのラベルを描画します。 |
| EndChangeCheck | Ends a code block and checks for any GUI changes. |
| EndDisabledGroup | BeginDisabledGroup で始まった Disabled group を終了します。 |
| * EndFoldoutHeaderGroup | Closes a group started with BeginFoldoutHeaderGroup. See Also: EditorGUILayout.BeginFoldoutHeaderGroup. |
| EndProperty | BeginProperty と開始した Property Wrapper を終了します。 |
| * EnumFlagsField | Displays a menu with an option for every value of the enum type when clicked. An option for the value 0 with name "Nothing" and an option for the value ~0 (that is, all bits set) with the name "Everything" are always displayed at the top of the menu. The names for the values 0 and ~0 can be overriden by defining these values in the enum type. |
| * EnumPopup | Makes an enum popup selection field. |
| * FloatField | Makes a text field for entering floats. |
| FocusTextInControl | 名前付きのテキストフィールドにキーボードフォーカスを移動し、コンテンツの編集を開始します。 |
| * Foldout | Makes a label with a foldout arrow to the left of it. |
| GetPropertyHeight | PropertyField 制御に必要な高さを取得します。 |
| * GradientField | Makes a field for editing a Gradient. |
| HandlePrefixLabel | Makes a label for some control. |
| * HelpBox | Makes a help box with a message to the user. |
| * InspectorTitlebar | Makes an inspector-window-like titlebar. |
| * IntField | Makes a text field for entering integers. |
| * IntPopup | Makes an integer popup selection field. |
| * IntSlider | Makes a slider the user can drag to change an integer value between a min and a max. |
| * LabelField | Makes a label field. (Useful for showing read-only info.) |
| * LayerField | Makes a layer selection field. |
| * LinkButton | Make a clickable link label. |
| * LongField | Makes a text field for entering long integers. |
| * MaskField | Makes a field for masks. |
| * MinMaxSlider | Makes a special slider the user can use to specify a range between a min and a max. |
| MultiFloatField | Makes a multi-control with text fields for entering multiple floats in the same line. |
| MultiIntField | Makes a multi-control with text fields for entering multiple integers in the same line. |
| MultiPropertyField | Makes a multi-control with several property fields in the same line. |
| * ObjectField | Makes an object field. You can assign objects either by drag and drop objects or by selecting an object using the Object Picker. |
| * PasswordField | Makes a text field where the user can enter a password. |
| * Popup | Makes a generic popup selection field. |
| * PrefixLabel | Makes a label in front of some control. |
| ProgressBar | Makes a progress bar. |
| * PropertyField | Use this to make a field for a SerializedProperty in the Editor. |
| * RectField | Makes an X, Y, W, and H field for entering a Rect. |
| * RectIntField | Makes an X, Y, W, and H field for entering a RectInt. |
| * SelectableLabel | Makes a selectable label field. (Useful for showing read-only info that can be copy-pasted.) |
| * Slider | Makes a slider the user can drag to change a value between a min and a max. |
| * TagField | Makes a tag selection field. |
| * TextArea | Makes a text area. |
| * TextField | Makes a text field. |
| * Toggle | Makes a toggle. |
| * ToggleLeft | Makes a toggle field where the toggle is to the left and the label immediately to the right of it. |
| * Vector2Field | Makes an X and Y field for entering a Vector2. |
| * Vector2IntField | Makes an X and Y integer field for entering a Vector2Int. |
| * Vector3Field | Makes an X, Y, and Z field for entering a Vector3. |
| * Vector3IntField | Makes an X, Y, and Z integer field for entering a Vector3Int. |
| * Vector4Field | Makes an X, Y, Z, and W field for entering a Vector4. |
EditorGUILayout
| BeginBuildTargetSelectionGrouping | Begin a build target grouping and get the selected BuildTargetGroup back. |
| BeginFadeGroup | 非表示/表示 と遷移アニメーションが可能なグループを作成します。 |
| * BeginFoldoutHeaderGroup | それの左側に折り畳み矢印でラベルを作成します。 |
| BeginHorizontal | 水平グループを開始し、戻る Rect を取得します。 |
| BeginScrollView | 自動的にレイアウトされるスクロールビューを開始します |
| BeginToggleGroup | 一度で中のすべてのコントロールを無効か有効にするトグルの垂直グループを開始します。 |
| BeginVertical | 垂直グループを開始し、戻る Rect を取得します。 |
| * BoundsField | Bounds を入力する Center と Extents フィールドを作成します。 |
| * BoundsIntField | Make Position & Size field for entering a BoundsInt. |
| * ColorField | Color を選択するフィールドをを作成します。 |
| * CurveField | AnimationCurve を編集するためのフィールドを作成します。 |
| * DelayedDoubleField | double を入力する Delayed のフィールドを作成します。 |
| * DelayedFloatField | float を入力するために Delayed Text Field を作成します。 |
| * DelayedIntField | 整数を入力するための Delayed Text Field を作成します。 |
| * DelayedTextField | Delayed Text Field を作成します。 |
| * DoubleField | double を入力するフィールドを作成します。 |
| * DropdownButton | Make a button that reacts to mouse down, for displaying your own dropdown content. |
| EditorToolbar | Makes a toolbar populated with the specified collection of editor tools. |
| EditorToolbarForTarget | Makes a toolbar populated with the collection of editor tools that match the EditorToolAttribute of the target object. |
| EndBuildTargetSelectionGrouping | Close a group started with BeginBuildTargetSelectionGrouping. |
| EndFadeGroup | BeginFadeGroup で始めたグループを閉じます。 |
| * EndFoldoutHeaderGroup | Closes a group started with BeginFoldoutHeaderGroup. |
| EndHorizontal | BeginHorizontal で開始したグループを閉じます |
| EndScrollView | BeginScrollView で開始されたスクロールビューを終了します |
| EndToggleGroup | BeginToggleGroup で始まっていたグループを閉じます。 |
| EndVertical | BeginVertical で開始したグループを閉じます |
| * EnumFlagsField | Displays a menu with an option for every value of the enum type when clicked. |
| * EnumPopup | enum をポップアップして選択するフィールドを作成します。 |
| * FloatField | float 値を入力するためのフィールドを作成します。 |
| * Foldout | それの左側に折り畳み矢印でラベルを作成します。 |
| GetControlRect | Editor control のために Rect を取得します。 |
| * GradientField | Make a field for editing a Gradient. |
| * HelpBox | ユーザーへのメッセージとヘルプボックスを作成します。 |
| * InspectorTitlebar | Inspector Window のような Titlebar を作成します。 |
| * IntField | 整数を入力するための Text Field を作成します。 |
| * IntPopup | 整数をポップアップして選択するフィールドを作成します。 |
| * IntSlider | 最小と最大の間の整数値をユーザーがドラッグして変更するスライダーを作成します。 |
| * LabelField | Label Field を作成します (読み取り専用の情報を表示するために便利です)。 |
| * LayerField | レイヤー選択フィールドを作成します。 |
| * LinkButton | Make a clickable link label. |
| * LongField | long の整数を入力するフィールドを作成します。 |
| * MaskField | Mask Field を作成します。 |
| * MinMaxSlider | ユーザーが最小と最大の間の範囲を指定して使用できる特別なスライダーを作成します。 |
| * ObjectField | 任意のオブジェクトの Type を表示するフィールドを作成します。 |
| * PasswordField | パスワードを入力するフィールドを作成します。 |
| * Popup | 一般的なポップアップ選択フィールドを作成します。 |
| * PrefixLabel | いくつかのコントロールの前にラベルを作成します。 |
| * PropertyField | SerializedProperty のフィールドを作成します。 |
| * RectField | Rect を入力する X 、 Y 、 W と H のフィールドを作成します。 |
| * RectIntField | Make an X, Y, W & H field for entering a RectInt. |
| * SelectableLabel | 選択可能な Label Field を作成します(コピーとペーストできる読み取り専用の情報を表示するために便利です)。 |
| * Slider | 最小と最大の間の整数値をユーザーがドラッグして変更するスライダーを作成します。 |
| Space | 前のコントロールと次のコントロールの間に小さなスペースを作成します。 |
| * TagField | タグを選択するフィールドを作成します。 |
| * TextArea | テキストの領域を作成します。 |
| * TextField | Text Field を作成します。 |
| * Toggle | Toggle を作成します。 |
| * ToggleLeft | トグルを左側に、そのすぐ右側にラベルがある Toggle Field を作成します。 |
| ToolContextToolbar | Makes a toolbar populated with the specified collection of editor tool contexts. |
| ToolContextToolbarForTarget | Makes a toolbar populated with the collection of EditorToolContext that match the EditorToolContextAttribute.targetType of the target object. |
| * Vector2Field | Vector2 を入力する X と Y のフィールドを作成します。 |
| * Vector2IntField | Make an X & Y integer field for entering a Vector2Int. |
| * Vector3Field | Vector3 を入力する X 、 Y と Z のフィールドを作成します。 |
| * Vector3IntField | Make an X, Y & Z integer field for entering a Vector3Int. |
| * Vector4Field | Vector4 を入力する X 、 Y 、 Z と W のフィールドを作成します。 |