ScenePartition/Editor/ScenePartitionDataSOEditor.cs

53 lines
1.8 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
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();
if (GUILayout.Button("Force Serialize"))
{
AssetDatabase.ForceReserializeAssets(new string[] { AssetDatabase.GetAssetPath(scenePartitionDataSO) }, ForceReserializeAssetsOptions.ReserializeAssetsAndMetadata);
}
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);
}
}
EditorGUILayout.Space();
if (scenePartitionDataSO.HasLoadedPartitions)
{
EditorGUILayout.LabelField($"loadedScenePartitions");
foreach (KeyValuePair<uint, ScenePartition> scenePartition in scenePartitionDataSO.LoadedScenePartitions)
{
EditorGUILayout.IntField((int)scenePartition.Value.id);
}
}
}
}
}
}