ScenePartition/Editor/ScenePartitionSOEditor.cs

68 lines
1.9 KiB
C#
Raw Normal View History

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();
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 (scenePartitionSO.scenePartitionData.hasCreatedPartitions)
2023-06-24 16:43:10 +02:00
{
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 });
}
}
}
}
}