Version: 2018.2
public static bool Foldout (bool foldout, string content, bool toggleOnLabelClick, GUIStyle style= EditorStyles.foldout);
public static bool Foldout (bool foldout, GUIContent content, bool toggleOnLabelClick, GUIStyle style= EditorStyles.foldout);
public static bool Foldout (bool foldout, string content, GUIStyle style= EditorStyles.foldout);
public static bool Foldout (bool foldout, GUIContent content, GUIStyle style= EditorStyles.foldout);

パラメーター

foldout表示されている折り畳みの状態
content表示するラベル
styleオプションの GUIStyle
toggleOnLabelClickWhether to toggle the foldout state when the label is clicked.

戻り値

bool ユーザーによって選択された折り畳みの状態。 True の場合、サブオブジェクトを表示する必要があります。

説明

それの左側に折り畳み矢印でラベルを作成します。

これは親が折り畳まれており、子オブジェクトを表示するような構造のツリーやフォルダーを作成するために便利です。


Foldout in an Editor Window.

// Create a foldable menu that hides/shows the selected transform position.
// If no Transform is selected, the Foldout item will be folded until
// a transform is selected.

using UnityEditor; using UnityEngine;

public class FoldoutUsage : EditorWindow { bool showPosition = true; string status = "Select a GameObject";

[MenuItem("Examples/Foldout Usage")] static void Init() { FoldoutUsage window = (FoldoutUsage)GetWindow(typeof(FoldoutUsage)); window.Show(); }

public void OnGUI() { showPosition = EditorGUILayout.Foldout(showPosition, status); if (showPosition) if (Selection.activeTransform) { Selection.activeTransform.position = EditorGUILayout.Vector3Field("Position", Selection.activeTransform.position); status = Selection.activeTransform.name; }

if (!Selection.activeTransform) { status = "Select a GameObject"; showPosition = false; } }

public void OnInspectorUpdate() { this.Repaint(); } }