Updated ScenePartitionEditorWindow

- Added clear button here instead of in ScenePartitionSOEditor
- Added editor util for horizontal line
- Exposed scene grid cell size value
This commit is contained in:
max 2023-07-04 23:34:54 +02:00
parent 80c90d884a
commit cf3198b0b7
5 changed files with 49 additions and 10 deletions

20
Editor/EditorGUIUtils.cs Normal file
View File

@ -0,0 +1,20 @@
using UnityEditor;
using UnityEngine;
namespace VertexColor.ScenePartition.Editor
{
public static class EditorGUIUtils
{
public static readonly Color horizontalLineColor = Color.white;
public static void HorizontalLine(Color color)
{
Color prev = GUI.color;
GUI.color = color;
EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
GUI.color = prev;
}
public static void HorizontalLine() => HorizontalLine(horizontalLineColor);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: befa2e31a4a6ae04696dcd5b72554ea4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -19,11 +19,23 @@ public static void ShowExample()
private void OnGUI() private void OnGUI()
{ {
if (GUILayout.Button("Save")) EditorGUILayout.LabelField("Cache", EditorStyles.boldLabel);
using (new EditorGUILayout.HorizontalScope())
{ {
ScenePartitionSS.Save(); if (GUILayout.Button("Save", EditorStyles.miniButtonLeft))
{
ScenePartitionSS.Save();
}
if (GUILayout.Button("Clear", EditorStyles.miniButtonRight))
{
ScenePartitionSS.Save();
}
} }
EditorGUIUtils.HorizontalLine();
DrawSceneDataCache(); DrawSceneDataCache();
} }

View File

@ -83,6 +83,8 @@ public override void OnInspectorGUI()
{ {
EditorGUILayout.LabelField($"generatedSceneGrid"); 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) foreach (KeyValuePair<int, GridList> item in scenePartitionSO.Data.SceneGrid.Grid)
{ {
EditorGUILayout.LongField("gridId", item.Key); EditorGUILayout.LongField("gridId", item.Key);
@ -97,12 +99,6 @@ public override void OnInspectorGUI()
EditorGUI.indentLevel--; EditorGUI.indentLevel--;
} }
} }
if (GUILayout.Button("ClearCache"))
{
scenePartitionSO.ClearCache();
ScenePartitionSS.instance.SceneDataCache.Clear();
}
} }
} }
} }

View File

@ -6,7 +6,7 @@ namespace VertexColor.ScenePartition
public class SceneGrid public class SceneGrid
{ {
[SerializeField] [SerializeField]
private int cellSize = 10; public int cellSize = 10;
[SerializeField] [SerializeField]
private SceneGridDictionary grid = new SceneGridDictionary(); private SceneGridDictionary grid = new SceneGridDictionary();