ScenePartition/Editor/ScenePartitionSOEditor.cs
max 3bba6da1a6 SerializationUtility
- Split local editor data into separate SO
- Serializable dicts, sorted lists and sorted sets
- Only delete and save loaded partitions
2023-06-25 15:51:54 +02:00

68 lines
1.9 KiB
C#

using UnityEditor;
using UnityEngine;
namespace VertexColor.ScenePartition.Editor
{
[CustomEditor(typeof(ScenePartitionSO))]
public class ScenePartitionSOEditor : UnityEditor.Editor
{
private int id = 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 (scenePartitionSO.scenePartitionData.hasCreatedPartitions)
{
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 = EditorGUILayout.IntField("id", id);
if (GUILayout.Button("Load Section"))
{
scenePartitionSO.LoadPartitions(new uint[1] { (uint)id });
}
}
}
}
}