Skip to content

Instantly share code, notes, and snippets.

@karljj1
Last active January 4, 2023 21:50
  • Star 14 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save karljj1/978d76de9c93b20bd9761825ccf08fdf to your computer and use it in GitHub Desktop.
using UnityEditor;
using UnityEngine.LowLevel;
using UnityEngine.UIElements;
public class ShowPlayerLoopWindow : EditorWindow
{
[MenuItem("Window/Player Loop")]
static void ShowWindow()
{
var wind = GetWindow<ShowPlayerLoopWindow>(false, "Player Loop");
wind.Show();
}
void OnEnable()
{
Refresh();
}
void Refresh()
{
rootVisualElement.Clear();
rootVisualElement.Add(new Button(Refresh) { text = "Refresh" });
var scrollView = new ScrollView();
rootVisualElement.Add(scrollView);
var loop = PlayerLoop.GetCurrentPlayerLoop();
ShowSystems(scrollView.contentContainer, loop.subSystemList, 0);
}
static void ShowSystems(VisualElement root, PlayerLoopSystem[] systems, int indent)
{
foreach (var playerLoopSystem in systems)
{
if (playerLoopSystem.subSystemList != null)
{
var foldout = new Foldout{ text = playerLoopSystem.type.Name, style = { left = indent * 15 }};
root.Add(foldout);
ShowSystems(foldout, playerLoopSystem.subSystemList, indent + 1);
}
else
{
root.Add(new Label(playerLoopSystem.type.Name) { style = { left = indent * 15 } });
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment