ScenePartition/Editor/ScenePartitionSOEditor.cs

103 lines
3.0 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 int 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 = EditorGUILayout.IntField("id", id);
if (GUILayout.Button("Load Section"))
{
scenePartitionSO.LoadPartitions(new uint[1] { (uint)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, List<uint>> item in scenePartitionSO.Data.SceneGrid.Grid)
{
EditorGUILayout.IntField("gridId", item.Key);
EditorGUI.indentLevel++;
foreach (uint id in item.Value)
{
EditorGUILayout.IntField((int)id);
}
EditorGUI.indentLevel--;
}
}
}
}
}
}