2023-06-28 01:07:27 +02:00
|
|
|
using System.Collections.Generic;
|
2023-06-24 14:27:50 +02:00
|
|
|
using UnityEditor;
|
2023-06-25 04:39:12 +02:00
|
|
|
using UnityEngine;
|
2023-06-24 14:27:50 +02:00
|
|
|
|
|
|
|
namespace VertexColor.ScenePartition.Editor
|
|
|
|
{
|
|
|
|
[CustomEditor(typeof(ScenePartitionSO))]
|
|
|
|
public class ScenePartitionSOEditor : UnityEditor.Editor
|
|
|
|
{
|
2023-07-03 23:35:29 +02:00
|
|
|
private ulong id = 0;
|
2023-06-28 01:07:27 +02:00
|
|
|
private int gridId = 0;
|
2023-06-25 04:39:12 +02:00
|
|
|
|
2023-06-24 14:27:50 +02:00
|
|
|
public override void OnInspectorGUI()
|
|
|
|
{
|
|
|
|
ScenePartitionSO scenePartitionSO = (target as ScenePartitionSO);
|
|
|
|
|
2023-06-25 04:39:12 +02:00
|
|
|
DrawDefaultInspector();
|
|
|
|
|
2023-06-24 14:27:50 +02:00
|
|
|
serializedObject.Update();
|
2023-06-24 16:43:10 +02:00
|
|
|
//EditorGUILayout.PropertyField(sceneAssetProperty);
|
2023-06-24 14:27:50 +02:00
|
|
|
serializedObject.ApplyModifiedProperties();
|
|
|
|
|
2023-06-24 16:43:10 +02:00
|
|
|
EditorGUILayout.Space();
|
2023-06-24 14:27:50 +02:00
|
|
|
|
2023-06-26 01:03:14 +02:00
|
|
|
if (scenePartitionSO.SceneAsset == null)
|
2023-06-24 14:27:50 +02:00
|
|
|
{
|
2023-06-24 16:43:10 +02:00
|
|
|
if (GUILayout.Button("Create Scene"))
|
|
|
|
{
|
|
|
|
scenePartitionSO.CreateScene();
|
|
|
|
}
|
2023-06-24 14:27:50 +02:00
|
|
|
}
|
2023-06-24 16:43:10 +02:00
|
|
|
else
|
2023-06-24 14:27:50 +02:00
|
|
|
{
|
2023-06-24 16:43:10 +02:00
|
|
|
if (GUILayout.Button("Load All"))
|
|
|
|
{
|
|
|
|
scenePartitionSO.LoadAll();
|
|
|
|
}
|
|
|
|
|
2023-06-27 01:09:28 +02:00
|
|
|
if (GUILayout.Button("Reload"))
|
|
|
|
{
|
|
|
|
scenePartitionSO.Reload();
|
|
|
|
}
|
|
|
|
|
2023-06-26 01:03:14 +02:00
|
|
|
if (GUILayout.Button("Save"))
|
2023-06-24 16:43:10 +02:00
|
|
|
{
|
2023-06-26 01:03:14 +02:00
|
|
|
scenePartitionSO.Save();
|
2023-06-24 16:43:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (GUILayout.Button("Unload"))
|
|
|
|
{
|
|
|
|
scenePartitionSO.Unload();
|
|
|
|
}
|
|
|
|
|
2023-06-25 04:39:12 +02:00
|
|
|
EditorGUILayout.Space();
|
|
|
|
|
2023-06-24 16:43:10 +02:00
|
|
|
if (GUILayout.Button("Open Scene Data Folder"))
|
|
|
|
{
|
|
|
|
EditorUtility.RevealInFinder(ScenePartitionUtils.GetDataPath(scenePartitionSO));
|
|
|
|
}
|
2023-06-25 04:39:12 +02:00
|
|
|
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
|
2023-07-03 23:35:29 +02:00
|
|
|
id = (ulong)EditorGUILayout.LongField("id", (long)id);
|
2023-06-25 04:39:12 +02:00
|
|
|
|
2023-06-25 15:51:54 +02:00
|
|
|
if (GUILayout.Button("Load Section"))
|
2023-06-25 04:39:12 +02:00
|
|
|
{
|
2023-07-03 23:35:29 +02:00
|
|
|
scenePartitionSO.LoadPartitions(new ulong[1] { id });
|
2023-06-25 04:39:12 +02:00
|
|
|
}
|
2023-06-28 01:07:27 +02:00
|
|
|
|
|
|
|
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");
|
|
|
|
|
2023-07-03 23:35:29 +02:00
|
|
|
foreach (KeyValuePair<int, GridList> item in scenePartitionSO.Data.SceneGrid.Grid)
|
2023-06-28 01:07:27 +02:00
|
|
|
{
|
2023-06-30 03:28:44 +02:00
|
|
|
EditorGUILayout.LongField("gridId", item.Key);
|
2023-06-28 01:07:27 +02:00
|
|
|
|
|
|
|
EditorGUI.indentLevel++;
|
|
|
|
|
2023-07-03 23:35:29 +02:00
|
|
|
foreach (ulong id in item.Value.list)
|
2023-06-28 01:07:27 +02:00
|
|
|
{
|
2023-07-03 23:35:29 +02:00
|
|
|
EditorGUILayout.LongField((long)id);
|
2023-06-28 01:07:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
EditorGUI.indentLevel--;
|
|
|
|
}
|
|
|
|
}
|
2023-06-30 03:28:44 +02:00
|
|
|
|
|
|
|
if (GUILayout.Button("ClearCache"))
|
|
|
|
{
|
|
|
|
scenePartitionSO.ClearCache();
|
|
|
|
ScenePartitionSS.instance.SceneDataCache.Clear();
|
|
|
|
}
|
2023-06-24 14:27:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|