ScenePartition/Editor/ScenePartitionDataSOEditor.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

66 lines
2.5 KiB
C#

using System.Collections.Generic;
using UnityEditor;
namespace VertexColor.ScenePartition.Editor
{
[CustomEditor(typeof(ScenePartitionDataSO))]
public class ScenePartitionDataSOEditor : UnityEditor.Editor
{
public override void OnInspectorGUI()
{
ScenePartitionDataSO scenePartitionDataSO = (target as ScenePartitionDataSO);
DrawDefaultInspector();
serializedObject.Update();
//EditorGUILayout.PropertyField(sceneAssetProperty);
serializedObject.ApplyModifiedProperties();
EditorGUILayout.Space();
using (new EditorGUI.DisabledGroupScope(true))
{
if (scenePartitionDataSO.hasCreatedPartitions)
{
EditorGUILayout.LabelField($"scenePartitions");
foreach (KeyValuePair<uint, ScenePartition> scenePartition in scenePartitionDataSO.scenePartitions)
{
EditorGUILayout.IntField((int)scenePartition.Value.id);
if (scenePartition.Value.references != null && scenePartition.Value.references.Count > 0)
{
EditorGUI.indentLevel++;
foreach (var reference in scenePartition.Value.references)
{
EditorGUILayout.IntField((int)reference);
}
EditorGUI.indentLevel--;
}
}
}
EditorGUILayout.Space();
if (scenePartitionDataSO.hasLoadedPartitions)
{
EditorGUILayout.LabelField($"loadedScenePartitions");
foreach (KeyValuePair<uint, ScenePartition> scenePartition in scenePartitionDataSO.loadedScenePartitions)
{
EditorGUILayout.IntField((int)scenePartition.Value.id);
if (scenePartition.Value.references != null && scenePartition.Value.references.Count > 0)
{
EditorGUI.indentLevel++;
foreach (var reference in scenePartition.Value.references)
{
EditorGUILayout.IntField((int)reference);
}
EditorGUI.indentLevel--;
}
}
}
}
}
}
}