ScenePartition/Editor/ScenePartitionSOEditor.cs

105 lines
3.1 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace VertexColor.ScenePartition.Editor
{
[CustomEditor(typeof(ScenePartitionSO))]
public class ScenePartitionSOEditor : UnityEditor.Editor
{
private ulong id = 0;
private int gridId = 0;
public override void OnInspectorGUI()
{
ScenePartitionSO scenePartitionSO = (target as ScenePartitionSO);
DrawDefaultInspector();
serializedObject.Update();
2023-06-24 16:43:10 +02:00
//EditorGUILayout.PropertyField(sceneAssetProperty);
serializedObject.ApplyModifiedProperties();
2023-06-24 16:43:10 +02:00
EditorGUILayout.Space();
if (scenePartitionSO.SceneAsset == null)
{
2023-06-24 16:43:10 +02:00
if (GUILayout.Button("Create Scene"))
{
scenePartitionSO.CreateScene();
}
}
2023-06-24 16:43:10 +02:00
else
{
2023-06-24 16:43:10 +02:00
if (GUILayout.Button("Load All"))
{
scenePartitionSO.LoadAll();
}
if (GUILayout.Button("Reload"))
{
scenePartitionSO.Reload();
}
if (GUILayout.Button("Save"))
2023-06-24 16:43:10 +02:00
{
scenePartitionSO.Save();
2023-06-24 16:43:10 +02:00
}
if (GUILayout.Button("Unload"))
{
scenePartitionSO.Unload();
}
EditorGUILayout.Space();
2023-06-24 16:43:10 +02:00
if (GUILayout.Button("Open Scene Data Folder"))
{
EditorUtility.RevealInFinder(ScenePartitionUtils.GetDataPath(scenePartitionSO));
}
EditorGUILayout.Space();
id = (ulong)EditorGUILayout.LongField("id", (long)id);
if (GUILayout.Button("Load Section"))
{
scenePartitionSO.LoadPartitions(new ulong[1] { id });
}
if (GUILayout.Button("GenerateSceneGrid"))
{
scenePartitionSO.GenerateSceneGridData();
}
gridId = EditorGUILayout.IntField("gridId", gridId);
if (GUILayout.Button("LoadSceneGrid"))
{
scenePartitionSO.LoadCell(gridId);
}
if (scenePartitionSO.Data.SceneGrid != null)
{
EditorGUILayout.LabelField($"generatedSceneGrid");
scenePartitionSO.Data.SceneGrid.cellSize = EditorGUILayout.IntSlider("cellSize", scenePartitionSO.Data.SceneGrid.cellSize, 10, 1000);
foreach (KeyValuePair<int, GridList> item in scenePartitionSO.Data.SceneGrid.Grid)
{
EditorGUILayout.LongField("gridId", item.Key);
EditorGUI.indentLevel++;
foreach (ulong id in item.Value.list)
{
EditorGUILayout.LongField((long)id);
}
EditorGUI.indentLevel--;
}
}
}
}
}
}