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;
|
|
|
|
|
|
|
|
[MenuItem("Max/ScenePartitionWindow")]
|
|
|
|
public static void ShowExample()
|
|
|
|
{
|
|
|
|
ScenePartitionEditorWindow window = GetWindow<ScenePartitionEditorWindow>();
|
|
|
|
window.titleContent = new GUIContent($"{nameof(ScenePartitionEditorWindow)}");
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnGUI()
|
|
|
|
{
|
2023-06-28 01:07:27 +02:00
|
|
|
if (GUILayout.Button("Save"))
|
|
|
|
{
|
|
|
|
ScenePartitionSS.Save();
|
|
|
|
}
|
|
|
|
|
2023-06-27 00:24:46 +02:00
|
|
|
DrawSceneDataCache();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void DrawSceneDataCache()
|
|
|
|
{
|
|
|
|
using (EditorGUILayout.ScrollViewScope scope = new EditorGUILayout.ScrollViewScope(scrollPos))
|
|
|
|
{
|
|
|
|
scrollPos = scope.scrollPosition;
|
|
|
|
|
|
|
|
using (new EditorGUI.DisabledGroupScope(true))
|
|
|
|
{
|
|
|
|
ScenePartitionSS scenePartitionSS = ScenePartitionSS.instance;
|
|
|
|
|
|
|
|
foreach (KeyValuePair<ScenePartitionSO, ScenePartitionData> sceneData in scenePartitionSS.SceneDataCache)
|
|
|
|
{
|
2023-06-30 03:28:44 +02:00
|
|
|
if (sceneData.Key == null || sceneData.Value == null) continue;
|
|
|
|
|
2023-06-27 00:24:46 +02:00
|
|
|
EditorGUILayout.LabelField($"{sceneData.Key.name}");
|
|
|
|
|
|
|
|
if (sceneData.Value.HasCreatedPartitions)
|
|
|
|
{
|
|
|
|
EditorGUILayout.LabelField($"scenePartitions");
|
|
|
|
|
2023-06-30 03:28:44 +02:00
|
|
|
foreach (KeyValuePair<long, ScenePartition> scenePartition in sceneData.Value.ScenePartitions)
|
2023-06-27 00:24:46 +02:00
|
|
|
{
|
2023-06-30 03:28:44 +02:00
|
|
|
EditorGUILayout.LongField(scenePartition.Key);
|
2023-06-27 00:24:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
|
|
|
|
if (sceneData.Value.HasLoadedPartitions)
|
|
|
|
{
|
|
|
|
EditorGUILayout.LabelField($"loadedScenePartitions");
|
|
|
|
|
2023-06-30 03:28:44 +02:00
|
|
|
foreach (KeyValuePair<long, ScenePartition> scenePartition in sceneData.Value.LoadedScenePartitions)
|
2023-06-27 00:24:46 +02:00
|
|
|
{
|
2023-06-30 03:28:44 +02:00
|
|
|
EditorGUILayout.LongField(scenePartition.Value.id);
|
2023-06-27 00:24:46 +02:00
|
|
|
}
|
|
|
|
}
|
2023-06-28 01:07:27 +02:00
|
|
|
|
|
|
|
if (sceneData.Value.SceneGrid != null)
|
|
|
|
{
|
|
|
|
EditorGUILayout.LabelField($"generatedSceneGrid");
|
|
|
|
|
2023-06-30 03:28:44 +02:00
|
|
|
foreach (KeyValuePair<int, List<long>> item in sceneData.Value.SceneGrid.Grid)
|
2023-06-28 01:07:27 +02:00
|
|
|
{
|
|
|
|
EditorGUILayout.IntField("gridId", item.Key);
|
|
|
|
|
|
|
|
EditorGUI.indentLevel++;
|
|
|
|
|
2023-06-30 03:28:44 +02:00
|
|
|
foreach (long id in item.Value)
|
2023-06-28 01:07:27 +02:00
|
|
|
{
|
2023-06-30 03:28:44 +02:00
|
|
|
EditorGUILayout.LongField(id);
|
2023-06-28 01:07:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
EditorGUI.indentLevel--;
|
|
|
|
}
|
|
|
|
}
|
2023-06-27 00:24:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|