ScenePartition/Editor/ScenePartitionSOEditor.cs

99 lines
3.2 KiB
C#
Raw Normal View History

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();
EditorGUIUtils.HorizontalLine();
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
{
if (GUILayout.Button("Open Scene Data Folder"))
2023-06-24 16:43:10 +02:00
{
EditorUtility.RevealInFinder(ScenePartitionUtils.GetDataPath(scenePartitionSO));
2023-06-24 16:43:10 +02:00
}
EditorGUIUtils.HorizontalLine();
2023-07-09 23:08:55 +02:00
if (GUILayout.Button("Load All"))
2023-06-24 16:43:10 +02:00
{
2023-07-09 23:08:55 +02:00
scenePartitionSO.LoadAll();
2023-06-24 16:43:10 +02:00
}
using (new EditorGUILayout.HorizontalScope())
2023-06-24 16:43:10 +02:00
{
2023-07-09 23:08:55 +02:00
if (GUILayout.Button(new GUIContent("Unload", "Empty the scene and save it (so it has no changes in source control)."), EditorStyles.miniButtonLeft))
{
2023-07-09 23:08:55 +02:00
scenePartitionSO.Unload();
}
2023-07-09 23:08:55 +02:00
if (GUILayout.Button(new GUIContent("Reload", "Discard changes and reload loaded partitions."), EditorStyles.miniButtonRight))
{
scenePartitionSO.Reload();
}
2023-06-24 16:43:10 +02:00
}
2023-07-09 23:08:55 +02:00
if (GUILayout.Button("Save"))
{
scenePartitionSO.Save();
}
2023-07-29 01:51:21 +02:00
EditorGUIUtils.HorizontalLine();
using (new EditorGUILayout.HorizontalScope())
2023-06-24 16:43:10 +02:00
{
id = (ulong)EditorGUILayout.LongField("id", (long)id);
if (GUILayout.Button("Load Id"))
{
scenePartitionSO.LoadPartitions(new ulong[1] { id });
}
}
EditorGUIUtils.HorizontalLine();
ScenePartitionSceneViewEditor.cellSize = EditorGUILayout.IntSlider("cellSize", ScenePartitionSceneViewEditor.cellSize, 10, 1000);
if (GUILayout.Button("GenerateSceneGrid"))
{
scenePartitionSO.GenerateSceneGridData();
}
if (scenePartitionSO.Data.SceneGrid != null)
{
2023-07-09 23:08:55 +02:00
using (new EditorGUILayout.HorizontalScope())
{
2023-07-09 23:08:55 +02:00
gridId = EditorGUILayout.IntField("gridId", gridId);
if (GUILayout.Button("LoadSceneGrid"))
{
scenePartitionSO.LoadCell(gridId);
}
}
}
}
}
}
}