generated from max/template-unity-project
122 lines
4.1 KiB
C#
122 lines
4.1 KiB
C#
using System.Collections.Generic;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace VertexColor.ScenePartition.Editor
|
|
{
|
|
[CustomEditor(typeof(ScenePartitionSO))]
|
|
public class ScenePartitionSOEditor : UnityEditor.Editor
|
|
{
|
|
private ulong id = 0;
|
|
private int gridId = 0;
|
|
private bool foldoutGroupEnabled = false;
|
|
|
|
public override void OnInspectorGUI()
|
|
{
|
|
ScenePartitionSO scenePartitionSO = (target as ScenePartitionSO);
|
|
|
|
DrawDefaultInspector();
|
|
|
|
serializedObject.Update();
|
|
//EditorGUILayout.PropertyField(sceneAssetProperty);
|
|
serializedObject.ApplyModifiedProperties();
|
|
|
|
EditorGUIUtils.HorizontalLine();
|
|
|
|
if (scenePartitionSO.SceneAsset == null)
|
|
{
|
|
if (GUILayout.Button("Create Scene"))
|
|
{
|
|
scenePartitionSO.CreateScene();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (GUILayout.Button("Open Scene Data Folder"))
|
|
{
|
|
EditorUtility.RevealInFinder(ScenePartitionUtils.GetDataPath(scenePartitionSO));
|
|
}
|
|
|
|
EditorGUIUtils.HorizontalLine();
|
|
|
|
if (GUILayout.Button("Load All"))
|
|
{
|
|
scenePartitionSO.LoadAll();
|
|
}
|
|
|
|
using (new EditorGUILayout.HorizontalScope())
|
|
{
|
|
if (GUILayout.Button(new GUIContent("Unload", "Empty the scene and save it (so it has no changes in source control)."), EditorStyles.miniButtonLeft))
|
|
{
|
|
scenePartitionSO.Unload();
|
|
}
|
|
|
|
if (GUILayout.Button(new GUIContent("Reload", "Discard changes and reload loaded partitions."), EditorStyles.miniButtonRight))
|
|
{
|
|
scenePartitionSO.Reload();
|
|
}
|
|
}
|
|
|
|
if (GUILayout.Button("Save"))
|
|
{
|
|
scenePartitionSO.Save();
|
|
}
|
|
|
|
using (new EditorGUILayout.HorizontalScope())
|
|
{
|
|
id = (ulong)EditorGUILayout.LongField("id", (long)id);
|
|
|
|
if (GUILayout.Button("Load Id"))
|
|
{
|
|
scenePartitionSO.LoadPartitions(new ulong[1] { id });
|
|
}
|
|
}
|
|
|
|
EditorGUIUtils.HorizontalLine();
|
|
|
|
ScenePartitionSceneViewEditor.cellSize = EditorGUILayout.IntSlider("cellSize", ScenePartitionSceneViewEditor.cellSize, 10, 1000);
|
|
|
|
if (GUILayout.Button("GenerateSceneGrid"))
|
|
{
|
|
scenePartitionSO.GenerateSceneGridData();
|
|
}
|
|
|
|
if (scenePartitionSO.Data.SceneGrid != null)
|
|
{
|
|
using (new EditorGUILayout.HorizontalScope())
|
|
{
|
|
gridId = EditorGUILayout.IntField("gridId", gridId);
|
|
|
|
if (GUILayout.Button("LoadSceneGrid"))
|
|
{
|
|
scenePartitionSO.LoadCell(gridId);
|
|
}
|
|
}
|
|
|
|
EditorGUIUtils.HorizontalLine();
|
|
|
|
using (EditorGUIUtils.FoldoutHeaderScope foldoutGroup = new EditorGUIUtils.FoldoutHeaderScope("gridData", ref foldoutGroupEnabled))
|
|
{
|
|
if (!foldoutGroupEnabled) return;
|
|
|
|
EditorGUILayout.LabelField($"generatedSceneGrid");
|
|
|
|
foreach (KeyValuePair<int, GridList> item in scenePartitionSO.Data.SceneGrid.Grid)
|
|
{
|
|
EditorGUILayout.LongField("gridId", item.Key);
|
|
|
|
EditorGUI.indentLevel++;
|
|
|
|
foreach (ulong id in item.Value.list)
|
|
{
|
|
EditorGUILayout.LongField((long)id);
|
|
}
|
|
|
|
EditorGUI.indentLevel--;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |