/// <summary> /// 绘制折页 /// </summary> /// <param name="taget"></param> /// <param name="name"></param> /// <param name="drawGUI"></param> public static void DrawFoldout(object taget, string name, CallBack drawGUI) { bool isFolder = EditorGUILayout.Foldout(EditorGUIState.GetState(taget), name); if (isFolder) { if (drawGUI != null) { drawGUI(); } } EditorGUIState.SetState(taget, isFolder); }
/// <summary> /// 绘制折页 /// </summary> /// <param name="taget"></param> /// <param name="name"></param> /// <param name="drawGUI"></param> public static void DrawFoldout(object taget, GUIContent content, CallBack drawGUI) { bool isFolder = EditorGUILayout.Foldout(EditorGUIState.GetState(taget), content); if (isFolder) { if (drawGUI != null) { drawGUI(); } } EditorGUIState.SetState(taget, isFolder); }
/// <summary> /// 绘制滚动视图 /// </summary> /// <param name="taget">状态储存的目标object</param> /// <param name="drawGUI"></param> /// <param name="style"></param> public static void DrawScrollView(object taget, CallBack drawGUI, string style = "") { Vector2 pos = EditorGUIState.GetVector2(taget); if (string.IsNullOrEmpty(style)) { pos = GUILayout.BeginScrollView(pos); } else { pos = GUILayout.BeginScrollView(pos, style); } if (drawGUI != null) { drawGUI(); } GUILayout.EndScrollView(); EditorGUIState.SetVector2(taget, pos); }