2023-06-24 14:27:50 +02:00
|
|
|
using UnityEditor;
|
2023-06-25 04:39:12 +02:00
|
|
|
using UnityEngine;
|
2023-06-24 14:27:50 +02:00
|
|
|
|
|
|
|
namespace VertexColor.ScenePartition.Editor
|
|
|
|
{
|
|
|
|
[CustomEditor(typeof(ScenePartitionSO))]
|
|
|
|
public class ScenePartitionSOEditor : UnityEditor.Editor
|
|
|
|
{
|
2023-06-25 04:39:12 +02:00
|
|
|
private int id = 0;
|
|
|
|
|
2023-06-24 14:27:50 +02:00
|
|
|
public override void OnInspectorGUI()
|
|
|
|
{
|
|
|
|
ScenePartitionSO scenePartitionSO = (target as ScenePartitionSO);
|
|
|
|
|
2023-06-25 04:39:12 +02:00
|
|
|
DrawDefaultInspector();
|
|
|
|
|
2023-06-24 14:27:50 +02:00
|
|
|
serializedObject.Update();
|
2023-06-24 16:43:10 +02:00
|
|
|
//EditorGUILayout.PropertyField(sceneAssetProperty);
|
2023-06-24 14:27:50 +02:00
|
|
|
serializedObject.ApplyModifiedProperties();
|
|
|
|
|
2023-06-24 16:43:10 +02:00
|
|
|
EditorGUILayout.Space();
|
2023-06-24 14:27:50 +02:00
|
|
|
|
2023-06-25 04:39:12 +02:00
|
|
|
if (scenePartitionSO.sceneAsset == null)
|
2023-06-24 14:27:50 +02:00
|
|
|
{
|
2023-06-24 16:43:10 +02:00
|
|
|
if (GUILayout.Button("Create Scene"))
|
|
|
|
{
|
|
|
|
scenePartitionSO.CreateScene();
|
|
|
|
}
|
2023-06-24 14:27:50 +02:00
|
|
|
}
|
2023-06-24 16:43:10 +02:00
|
|
|
else
|
2023-06-24 14:27:50 +02:00
|
|
|
{
|
2023-06-24 16:43:10 +02:00
|
|
|
if (GUILayout.Button("Load All"))
|
|
|
|
{
|
|
|
|
scenePartitionSO.LoadAll();
|
|
|
|
}
|
|
|
|
|
2023-06-25 04:39:12 +02:00
|
|
|
if (scenePartitionSO.hasCreatedPartitions)
|
2023-06-24 16:43:10 +02:00
|
|
|
{
|
|
|
|
if (GUILayout.Button("Save All"))
|
|
|
|
{
|
|
|
|
scenePartitionSO.SaveAll();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GUILayout.Button("Unload"))
|
|
|
|
{
|
|
|
|
scenePartitionSO.Unload();
|
|
|
|
}
|
|
|
|
|
2023-06-25 04:39:12 +02:00
|
|
|
EditorGUILayout.Space();
|
|
|
|
|
2023-06-24 16:43:10 +02:00
|
|
|
if (GUILayout.Button("Open Scene Data Folder"))
|
|
|
|
{
|
|
|
|
EditorUtility.RevealInFinder(ScenePartitionUtils.GetDataPath(scenePartitionSO));
|
|
|
|
}
|
2023-06-25 04:39:12 +02:00
|
|
|
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
|
|
|
|
id = EditorGUILayout.IntField("id", id);
|
|
|
|
|
|
|
|
if (GUILayout.Button("Test Load"))
|
|
|
|
{
|
|
|
|
scenePartitionSO.LoadPartitions(new uint[1] { (uint)id });
|
|
|
|
}
|
2023-06-24 14:27:50 +02:00
|
|
|
}
|
|
|
|
|
2023-06-24 16:43:10 +02:00
|
|
|
EditorGUILayout.Space();
|
|
|
|
|
|
|
|
using (new EditorGUI.DisabledGroupScope(true))
|
2023-06-24 14:27:50 +02:00
|
|
|
{
|
2023-06-25 04:39:12 +02:00
|
|
|
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--;
|
|
|
|
}
|
|
|
|
}
|
2023-06-24 14:27:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|