Skip to content

Instantly share code, notes, and snippets.

@Novack
Forked from karljj1/ShowPlayerLoopWindow.cs
Created August 16, 2020 01:21
Show Gist options
  • Save Novack/b9361a5b84685328a870632f8c191f0f to your computer and use it in GitHub Desktop.
Save Novack/b9361a5b84685328a870632f8c191f0f 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()
{
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