SceneDebugViewer/Editor/SceneDebugViewerWindow.cs

80 lines
1.8 KiB
C#
Raw Normal View History

2021-03-31 01:20:21 +02:00
using System.Collections.Generic;
2021-03-30 15:36:30 +02:00
using UnityEngine;
using UnityEditor;
namespace TAO.SceneDebugViewer.Editor
{
public class SceneDebugViewerWindow : EditorWindow
{
2021-03-31 01:20:21 +02:00
private static SceneDebugViewerWindow window = null;
private static List<ReplacementShaderSetupScriptableObject> options = new List<ReplacementShaderSetupScriptableObject>();
2021-03-30 15:36:30 +02:00
[MenuItem("Window/SceneDebugViewer")]
static void Init()
{
2021-03-31 01:20:21 +02:00
Load();
2021-03-31 01:20:21 +02:00
window = (SceneDebugViewerWindow)GetWindow(typeof(SceneDebugViewerWindow));
window.titleContent = new GUIContent("SDV");
2021-03-31 14:01:01 +02:00
window.maxSize = new Vector2(101, window.maxSize.y);
window.minSize = new Vector2(101, window.minSize.y);
window.Show();
}
private void OnGUI()
{
2021-03-31 01:20:21 +02:00
using (new GUILayout.VerticalScope())
{
2021-03-31 01:20:21 +02:00
if (GUILayout.Button("Reload"))
{
2021-03-31 01:20:21 +02:00
Load();
}
2021-03-31 01:20:21 +02:00
GUILayout.Space(6);
if (GUILayout.Button("Default", GUILayout.Height(44)))
{
2021-03-31 01:20:21 +02:00
foreach (SceneView s in SceneView.sceneViews)
{
s.SetSceneViewShaderReplace(null, null);
s.Repaint();
}
}
2021-03-31 01:20:21 +02:00
GUILayout.Space(6);
2021-03-31 14:01:01 +02:00
for (int i = 0; i < options.Count; i += 2)
2021-03-31 01:20:21 +02:00
{
2021-03-31 14:01:01 +02:00
GUILayout.BeginHorizontal();
if (GUILayout.Button(options[i].content, GUILayout.Height(44)))
2021-03-31 01:20:21 +02:00
{
2021-03-31 14:01:01 +02:00
options[i].Replace();
2021-03-31 01:20:21 +02:00
}
2021-03-31 14:01:01 +02:00
if (i + 1 < options.Count)
{
if (GUILayout.Button(options[i + 1].content, GUILayout.Height(44)))
{
options[i + 1].Replace();
}
}
GUILayout.EndHorizontal();
2021-03-31 01:20:21 +02:00
}
}
}
private static void Load()
{
options.Clear();
string[] guids = AssetDatabase.FindAssets("t:ReplacementShaderSetupScriptableObject", null);
foreach (string guid in guids)
{
options.Add((ReplacementShaderSetupScriptableObject)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guid), typeof(ReplacementShaderSetupScriptableObject)));
}
}
}
}