ScenePartition/Editor/ScenePartitionSOEditor.cs
max b067522a95 ScenePartitionObject
- Loading
- Partial loading
- Saving
2023-06-25 04:39:12 +02:00

107 lines
3.5 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.hasCreatedPartitions)
{
if (GUILayout.Button("Save All"))
{
scenePartitionSO.SaveAll();
}
}
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("Test Load"))
{
scenePartitionSO.LoadPartitions(new uint[1] { (uint)id });
}
}
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--;
}
}
}
}
}
}