generated from max/template-unity-project
max
cf3198b0b7
- Added clear button here instead of in ScenePartitionSOEditor - Added editor util for horizontal line - Exposed scene grid cell size value
105 lines
3.1 KiB
C#
105 lines
3.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;
|
|
|
|
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 (GUILayout.Button("Reload"))
|
|
{
|
|
scenePartitionSO.Reload();
|
|
}
|
|
|
|
if (GUILayout.Button("Save"))
|
|
{
|
|
scenePartitionSO.Save();
|
|
}
|
|
|
|
if (GUILayout.Button("Unload"))
|
|
{
|
|
scenePartitionSO.Unload();
|
|
}
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
if (GUILayout.Button("Open Scene Data Folder"))
|
|
{
|
|
EditorUtility.RevealInFinder(ScenePartitionUtils.GetDataPath(scenePartitionSO));
|
|
}
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
id = (ulong)EditorGUILayout.LongField("id", (long)id);
|
|
|
|
if (GUILayout.Button("Load Section"))
|
|
{
|
|
scenePartitionSO.LoadPartitions(new ulong[1] { id });
|
|
}
|
|
|
|
if (GUILayout.Button("GenerateSceneGrid"))
|
|
{
|
|
scenePartitionSO.GenerateSceneGridData();
|
|
}
|
|
|
|
gridId = EditorGUILayout.IntField("gridId", gridId);
|
|
|
|
if (GUILayout.Button("LoadSceneGrid"))
|
|
{
|
|
scenePartitionSO.LoadCell(gridId);
|
|
}
|
|
|
|
if (scenePartitionSO.Data.SceneGrid != null)
|
|
{
|
|
EditorGUILayout.LabelField($"generatedSceneGrid");
|
|
|
|
scenePartitionSO.Data.SceneGrid.cellSize = EditorGUILayout.IntSlider("cellSize", scenePartitionSO.Data.SceneGrid.cellSize, 10, 1000);
|
|
|
|
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--;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |