ScenePartition/Editor/ScenePartitionEditorWindow.cs

109 lines
4.1 KiB
C#
Raw Normal View History

2023-06-27 00:24:46 +02:00
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace VertexColor.ScenePartition.Editor
{
public class ScenePartitionEditorWindow : EditorWindow
{
2023-06-29 00:20:01 +02:00
private const int cellSize = 10;
2023-06-27 00:24:46 +02:00
private Vector2 scrollPos = Vector2.zero;
private bool foldoutGroupEnabled = false;
2023-06-27 00:24:46 +02:00
[MenuItem("Window/ScenePartition")]
2023-06-27 00:24:46 +02:00
public static void ShowExample()
{
ScenePartitionEditorWindow window = GetWindow<ScenePartitionEditorWindow>();
window.titleContent = new GUIContent($"{nameof(ScenePartitionEditorWindow)}");
}
private void OnGUI()
{
EditorGUILayout.LabelField("Cache", EditorStyles.boldLabel);
using (new EditorGUILayout.HorizontalScope())
{
if (GUILayout.Button("Save", EditorStyles.miniButtonLeft))
{
ScenePartitionSS.Save();
}
if (GUILayout.Button("Clear", EditorStyles.miniButtonRight))
{
ScenePartitionSS.Save();
}
}
EditorGUIUtils.HorizontalLine();
2023-06-27 00:24:46 +02:00
DrawSceneDataCache();
}
private void DrawSceneDataCache()
{
using (EditorGUIUtils.FoldoutHeaderScope foldoutGroup = new EditorGUIUtils.FoldoutHeaderScope("SceneDataCache", ref foldoutGroupEnabled))
2023-06-27 00:24:46 +02:00
{
if (!foldoutGroupEnabled) return;
2023-06-27 00:24:46 +02:00
using (EditorGUILayout.ScrollViewScope scope = new EditorGUILayout.ScrollViewScope(scrollPos))
2023-06-27 00:24:46 +02:00
{
scrollPos = scope.scrollPosition;
2023-06-27 00:24:46 +02:00
using (new EditorGUI.DisabledGroupScope(true))
2023-06-27 00:24:46 +02:00
{
ScenePartitionSS scenePartitionSS = ScenePartitionSS.instance;
foreach (KeyValuePair<ScenePartitionSO, ScenePartitionData> sceneData in scenePartitionSS.SceneDataCache)
2023-06-27 00:24:46 +02:00
{
if (sceneData.Key == null || sceneData.Value == null) continue;
EditorGUILayout.LabelField($"{sceneData.Key.name}");
2023-06-27 00:24:46 +02:00
if (sceneData.Value.HasCreatedPartitions)
2023-06-27 00:24:46 +02:00
{
EditorGUILayout.LabelField($"scenePartitions");
2023-06-27 00:24:46 +02:00
foreach (KeyValuePair<ulong, ScenePartition> scenePartition in sceneData.Value.ScenePartitions)
{
EditorGUILayout.LongField((long)scenePartition.Key);
}
}
2023-06-27 00:24:46 +02:00
EditorGUILayout.Space();
2023-06-27 00:24:46 +02:00
if (sceneData.Value.HasLoadedPartitions)
2023-06-27 00:24:46 +02:00
{
EditorGUILayout.LabelField($"loadedScenePartitions");
foreach (KeyValuePair<ulong, ScenePartition> scenePartition in sceneData.Value.LoadedScenePartitions)
{
EditorGUILayout.LongField((long)scenePartition.Value.id);
}
}
if (sceneData.Value.SceneGrid != null)
{
EditorGUILayout.LabelField($"generatedSceneGrid");
foreach (KeyValuePair<int, GridList> item in sceneData.Value.SceneGrid.Grid)
{
EditorGUILayout.IntField("gridId", item.Key);
EditorGUI.indentLevel++;
foreach (ulong id in item.Value.list)
{
EditorGUILayout.LongField((long)id);
}
EditorGUI.indentLevel--;
}
}
}
2023-06-27 00:24:46 +02:00
}
}
}
}
}
}