ScenePartition/Editor/ScenePartitionSOEditor.cs
max 80c90d884a ulong and grid list wrapper test
- wrapped lists in serialized dicts do work, maybe wrap anything.
- note: maybe convert long fields to string fields to support ulong?
2023-07-03 23:35:29 +02:00

109 lines
3.2 KiB
C#

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();
//EditorGUILayout.PropertyField(sceneAssetProperty);
serializedObject.ApplyModifiedProperties();
EditorGUILayout.Space();
if (scenePartitionSO.SceneAsset == null)
{
if (GUILayout.Button("Create Scene"))
{
scenePartitionSO.CreateScene();
}
}
else
{
if (GUILayout.Button("Load All"))
{
scenePartitionSO.LoadAll();
}
if (GUILayout.Button("Reload"))
{
scenePartitionSO.Reload();
}
if (GUILayout.Button("Save"))
{
scenePartitionSO.Save();
}
if (GUILayout.Button("Unload"))
{
scenePartitionSO.Unload();
}
EditorGUILayout.Space();
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");
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--;
}
}
if (GUILayout.Button("ClearCache"))
{
scenePartitionSO.ClearCache();
ScenePartitionSS.instance.SceneDataCache.Clear();
}
}
}
}
}