ScenePartition/Editor/ScenePartitionSOEditor.cs

107 lines
3.5 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.hasCreatedPartitions)
2023-06-24 16:43:10 +02:00
{
if (GUILayout.Button("Save All"))
{
scenePartitionSO.SaveAll();
}
}
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("Test Load"))
{
scenePartitionSO.LoadPartitions(new uint[1] { (uint)id });
}
}
2023-06-24 16:43:10 +02:00
EditorGUILayout.Space();
using (new EditorGUI.DisabledGroupScope(true))
{
if (scenePartitionSO.hasCreatedPartitions)
{
EditorGUILayout.LabelField($"scenePartitions");
foreach (System.Collections.Generic.KeyValuePair<uint, ScenePartition> scenePartition in scenePartitionSO.scenePartitions)
{
EditorGUILayout.IntField((int)scenePartition.Value.id);
EditorGUI.indentLevel++;
foreach (var reference in scenePartition.Value.references)
{
EditorGUILayout.IntField((int)reference);
}
EditorGUI.indentLevel--;
}
}
EditorGUILayout.Space();
if (scenePartitionSO.hasLoadedPartitions)
{
EditorGUILayout.LabelField($"loadedScenePartitions");
foreach (System.Collections.Generic.KeyValuePair<uint, ScenePartition> scenePartition in scenePartitionSO.loadedScenePartitions)
{
EditorGUILayout.IntField((int)scenePartition.Value.id);
EditorGUI.indentLevel++;
foreach (var reference in scenePartition.Value.references)
{
EditorGUILayout.IntField((int)reference);
}
EditorGUI.indentLevel--;
}
}
}
}
}
}