generated from max/template-unity-project
Compare commits
No commits in common. "8b44c33813aa5f8386482b2f42476a2d76d43d40" and "41df190afb2a3d2d44b758532b220a4a13231be2" have entirely different histories.
8b44c33813
...
41df190afb
@ -16,18 +16,5 @@ public static void HorizontalLine(Color color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void HorizontalLine() => HorizontalLine(horizontalLineColor);
|
public static void HorizontalLine() => HorizontalLine(horizontalLineColor);
|
||||||
|
|
||||||
public class FoldoutHeaderScope : System.IDisposable
|
|
||||||
{
|
|
||||||
public FoldoutHeaderScope(string label, ref bool foldout)
|
|
||||||
{
|
|
||||||
foldout = EditorGUILayout.BeginFoldoutHeaderGroup(foldout, label);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
EditorGUILayout.EndFoldoutHeaderGroup();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,9 +9,8 @@ public class ScenePartitionEditorWindow : EditorWindow
|
|||||||
private const int cellSize = 10;
|
private const int cellSize = 10;
|
||||||
|
|
||||||
private Vector2 scrollPos = Vector2.zero;
|
private Vector2 scrollPos = Vector2.zero;
|
||||||
private bool foldoutGroupEnabled = false;
|
|
||||||
|
|
||||||
[MenuItem("Window/ScenePartition")]
|
[MenuItem("Max/ScenePartitionWindow")]
|
||||||
public static void ShowExample()
|
public static void ShowExample()
|
||||||
{
|
{
|
||||||
ScenePartitionEditorWindow window = GetWindow<ScenePartitionEditorWindow>();
|
ScenePartitionEditorWindow window = GetWindow<ScenePartitionEditorWindow>();
|
||||||
@ -42,63 +41,58 @@ private void OnGUI()
|
|||||||
|
|
||||||
private void DrawSceneDataCache()
|
private void DrawSceneDataCache()
|
||||||
{
|
{
|
||||||
using (EditorGUIUtils.FoldoutHeaderScope foldoutGroup = new EditorGUIUtils.FoldoutHeaderScope("SceneDataCache", ref foldoutGroupEnabled))
|
using (EditorGUILayout.ScrollViewScope scope = new EditorGUILayout.ScrollViewScope(scrollPos))
|
||||||
{
|
{
|
||||||
if (!foldoutGroupEnabled) return;
|
scrollPos = scope.scrollPosition;
|
||||||
|
|
||||||
using (EditorGUILayout.ScrollViewScope scope = new EditorGUILayout.ScrollViewScope(scrollPos))
|
using (new EditorGUI.DisabledGroupScope(true))
|
||||||
{
|
{
|
||||||
scrollPos = scope.scrollPosition;
|
ScenePartitionSS scenePartitionSS = ScenePartitionSS.instance;
|
||||||
|
|
||||||
using (new EditorGUI.DisabledGroupScope(true))
|
foreach (KeyValuePair<ScenePartitionSO, ScenePartitionData> sceneData in scenePartitionSS.SceneDataCache)
|
||||||
{
|
{
|
||||||
ScenePartitionSS scenePartitionSS = ScenePartitionSS.instance;
|
if (sceneData.Key == null || sceneData.Value == null) continue;
|
||||||
|
|
||||||
foreach (KeyValuePair<ScenePartitionSO, ScenePartitionData> sceneData in scenePartitionSS.SceneDataCache)
|
EditorGUILayout.LabelField($"{sceneData.Key.name}");
|
||||||
|
|
||||||
|
if (sceneData.Value.HasCreatedPartitions)
|
||||||
{
|
{
|
||||||
if (sceneData.Key == null || sceneData.Value == null) continue;
|
EditorGUILayout.LabelField($"scenePartitions");
|
||||||
|
|
||||||
EditorGUILayout.LabelField($"{sceneData.Key.name}");
|
foreach (KeyValuePair<ulong, ScenePartition> scenePartition in sceneData.Value.ScenePartitions)
|
||||||
|
|
||||||
if (sceneData.Value.HasCreatedPartitions)
|
|
||||||
{
|
{
|
||||||
EditorGUILayout.LabelField($"scenePartitions");
|
EditorGUILayout.LongField((long)scenePartition.Key);
|
||||||
|
|
||||||
foreach (KeyValuePair<ulong, ScenePartition> scenePartition in sceneData.Value.ScenePartitions)
|
|
||||||
{
|
|
||||||
EditorGUILayout.LongField((long)scenePartition.Key);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EditorGUILayout.Space();
|
EditorGUILayout.Space();
|
||||||
|
|
||||||
if (sceneData.Value.HasLoadedPartitions)
|
if (sceneData.Value.HasLoadedPartitions)
|
||||||
|
{
|
||||||
|
EditorGUILayout.LabelField($"loadedScenePartitions");
|
||||||
|
|
||||||
|
foreach (KeyValuePair<ulong, ScenePartition> scenePartition in sceneData.Value.LoadedScenePartitions)
|
||||||
{
|
{
|
||||||
EditorGUILayout.LabelField($"loadedScenePartitions");
|
EditorGUILayout.LongField((long)scenePartition.Value.id);
|
||||||
|
|
||||||
foreach (KeyValuePair<ulong, ScenePartition> scenePartition in sceneData.Value.LoadedScenePartitions)
|
|
||||||
{
|
|
||||||
EditorGUILayout.LongField((long)scenePartition.Value.id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (sceneData.Value.SceneGrid != null)
|
if (sceneData.Value.SceneGrid != null)
|
||||||
|
{
|
||||||
|
EditorGUILayout.LabelField($"generatedSceneGrid");
|
||||||
|
|
||||||
|
foreach (KeyValuePair<int, GridList> item in sceneData.Value.SceneGrid.Grid)
|
||||||
{
|
{
|
||||||
EditorGUILayout.LabelField($"generatedSceneGrid");
|
EditorGUILayout.IntField("gridId", item.Key);
|
||||||
|
|
||||||
foreach (KeyValuePair<int, GridList> item in sceneData.Value.SceneGrid.Grid)
|
EditorGUI.indentLevel++;
|
||||||
|
|
||||||
|
foreach (ulong id in item.Value.list)
|
||||||
{
|
{
|
||||||
EditorGUILayout.IntField("gridId", item.Key);
|
EditorGUILayout.LongField((long)id);
|
||||||
|
|
||||||
EditorGUI.indentLevel++;
|
|
||||||
|
|
||||||
foreach (ulong id in item.Value.list)
|
|
||||||
{
|
|
||||||
EditorGUILayout.LongField((long)id);
|
|
||||||
}
|
|
||||||
|
|
||||||
EditorGUI.indentLevel--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EditorGUI.indentLevel--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
using UnityEditor;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace VertexColor.ScenePartition.Editor
|
|
||||||
{
|
|
||||||
public static class ScenePartitionMenuEditor
|
|
||||||
{
|
|
||||||
[MenuItem("GameObject/CopyFileId", false, 10000)]
|
|
||||||
public static void CreateTextArea5()
|
|
||||||
{
|
|
||||||
GameObject go = Selection.activeGameObject;
|
|
||||||
|
|
||||||
if (go == null) return;
|
|
||||||
|
|
||||||
GlobalObjectId id = GlobalObjectId.GetGlobalObjectIdSlow(go);
|
|
||||||
|
|
||||||
if (id.targetPrefabId == 0) // 0 = no prefab.
|
|
||||||
{
|
|
||||||
EditorGUIUtility.systemCopyBuffer = id.targetObjectId.ToString();
|
|
||||||
Debug.Log($"object id: {id.targetObjectId}");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EditorGUIUtility.systemCopyBuffer = id.targetPrefabId.ToString();
|
|
||||||
Debug.Log($"object id: {id.targetPrefabId}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: ab63a69b46a3ff4438723520d0656c93
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -281,11 +281,11 @@ public void GenerateSceneGridData()
|
|||||||
|
|
||||||
if (ids[i].targetPrefabId == 0) // 0 = no prefab.
|
if (ids[i].targetPrefabId == 0) // 0 = no prefab.
|
||||||
{
|
{
|
||||||
Data.SceneGrid.Insert(ids[i].targetObjectId, rootGameObjects[i].transform.position, ScenePartitionSceneViewEditor.cellSize);
|
Data.SceneGrid.Insert(ids[i].targetObjectId, rootGameObjects[i].transform.position);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Data.SceneGrid.Insert(ids[i].targetPrefabId, rootGameObjects[i].transform.position, ScenePartitionSceneViewEditor.cellSize);
|
Data.SceneGrid.Insert(ids[i].targetPrefabId, rootGameObjects[i].transform.position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ public class ScenePartitionSOEditor : UnityEditor.Editor
|
|||||||
{
|
{
|
||||||
private ulong id = 0;
|
private ulong id = 0;
|
||||||
private int gridId = 0;
|
private int gridId = 0;
|
||||||
private bool foldoutGroupEnabled = false;
|
|
||||||
|
|
||||||
public override void OnInspectorGUI()
|
public override void OnInspectorGUI()
|
||||||
{
|
{
|
||||||
@ -21,7 +20,7 @@ public override void OnInspectorGUI()
|
|||||||
//EditorGUILayout.PropertyField(sceneAssetProperty);
|
//EditorGUILayout.PropertyField(sceneAssetProperty);
|
||||||
serializedObject.ApplyModifiedProperties();
|
serializedObject.ApplyModifiedProperties();
|
||||||
|
|
||||||
EditorGUIUtils.HorizontalLine();
|
EditorGUILayout.Space();
|
||||||
|
|
||||||
if (scenePartitionSO.SceneAsset == null)
|
if (scenePartitionSO.SceneAsset == null)
|
||||||
{
|
{
|
||||||
@ -32,88 +31,72 @@ public override void OnInspectorGUI()
|
|||||||
}
|
}
|
||||||
else
|
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"))
|
if (GUILayout.Button("Open Scene Data Folder"))
|
||||||
{
|
{
|
||||||
EditorUtility.RevealInFinder(ScenePartitionUtils.GetDataPath(scenePartitionSO));
|
EditorUtility.RevealInFinder(ScenePartitionUtils.GetDataPath(scenePartitionSO));
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorGUIUtils.HorizontalLine();
|
EditorGUILayout.Space();
|
||||||
|
|
||||||
using (new EditorGUILayout.HorizontalScope())
|
id = (ulong)EditorGUILayout.LongField("id", (long)id);
|
||||||
|
|
||||||
|
if (GUILayout.Button("Load Section"))
|
||||||
{
|
{
|
||||||
if (GUILayout.Button("Load All", EditorStyles.miniButtonLeft))
|
scenePartitionSO.LoadPartitions(new ulong[1] { id });
|
||||||
{
|
|
||||||
scenePartitionSO.LoadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GUILayout.Button("Unload", EditorStyles.miniButtonRight))
|
|
||||||
{
|
|
||||||
scenePartitionSO.Unload();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
using (new EditorGUILayout.HorizontalScope())
|
|
||||||
{
|
|
||||||
if (GUILayout.Button("Save", EditorStyles.miniButtonLeft))
|
|
||||||
{
|
|
||||||
scenePartitionSO.Save();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GUILayout.Button(new GUIContent("Reload", "Discard changes and reload"), EditorStyles.miniButtonRight))
|
|
||||||
{
|
|
||||||
scenePartitionSO.Reload();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EditorGUIUtils.HorizontalLine();
|
|
||||||
|
|
||||||
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"))
|
if (GUILayout.Button("GenerateSceneGrid"))
|
||||||
{
|
{
|
||||||
scenePartitionSO.GenerateSceneGridData();
|
scenePartitionSO.GenerateSceneGridData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gridId = EditorGUILayout.IntField("gridId", gridId);
|
||||||
|
|
||||||
|
if (GUILayout.Button("LoadSceneGrid"))
|
||||||
|
{
|
||||||
|
scenePartitionSO.LoadCell(gridId);
|
||||||
|
}
|
||||||
|
|
||||||
if (scenePartitionSO.Data.SceneGrid != null)
|
if (scenePartitionSO.Data.SceneGrid != null)
|
||||||
{
|
{
|
||||||
gridId = EditorGUILayout.IntField("gridId", gridId);
|
EditorGUILayout.LabelField($"generatedSceneGrid");
|
||||||
|
|
||||||
if (GUILayout.Button("LoadSceneGrid"))
|
scenePartitionSO.Data.SceneGrid.cellSize = EditorGUILayout.IntSlider("cellSize", scenePartitionSO.Data.SceneGrid.cellSize, 10, 1000);
|
||||||
|
|
||||||
|
foreach (KeyValuePair<int, GridList> item in scenePartitionSO.Data.SceneGrid.Grid)
|
||||||
{
|
{
|
||||||
scenePartitionSO.LoadCell(gridId);
|
EditorGUILayout.LongField("gridId", item.Key);
|
||||||
}
|
|
||||||
|
|
||||||
using (EditorGUIUtils.FoldoutHeaderScope foldoutGroup = new EditorGUIUtils.FoldoutHeaderScope("gridData", ref foldoutGroupEnabled))
|
EditorGUI.indentLevel++;
|
||||||
{
|
|
||||||
if (!foldoutGroupEnabled) return;
|
|
||||||
|
|
||||||
EditorGUILayout.LabelField($"generatedSceneGrid");
|
foreach (ulong id in item.Value.list)
|
||||||
|
|
||||||
foreach (KeyValuePair<int, GridList> item in scenePartitionSO.Data.SceneGrid.Grid)
|
|
||||||
{
|
{
|
||||||
EditorGUILayout.LongField("gridId", item.Key);
|
EditorGUILayout.LongField((long)id);
|
||||||
|
|
||||||
EditorGUI.indentLevel++;
|
|
||||||
|
|
||||||
foreach (ulong id in item.Value.list)
|
|
||||||
{
|
|
||||||
EditorGUILayout.LongField((long)id);
|
|
||||||
}
|
|
||||||
|
|
||||||
EditorGUI.indentLevel--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EditorGUI.indentLevel--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,6 @@ namespace VertexColor.ScenePartition.Editor
|
|||||||
[InitializeOnLoad]
|
[InitializeOnLoad]
|
||||||
public class ScenePartitionSceneViewEditor : UnityEditor.Editor
|
public class ScenePartitionSceneViewEditor : UnityEditor.Editor
|
||||||
{
|
{
|
||||||
public static int cellSize = 100;
|
|
||||||
|
|
||||||
private static ScenePartitionSO scenePartitionSO = null;
|
private static ScenePartitionSO scenePartitionSO = null;
|
||||||
|
|
||||||
static ScenePartitionSceneViewEditor()
|
static ScenePartitionSceneViewEditor()
|
||||||
@ -20,6 +18,7 @@ private static void HandleDuringSceneGui(SceneView sceneView)
|
|||||||
if (Event.current.modifiers != EventModifiers.Control) return;
|
if (Event.current.modifiers != EventModifiers.Control) return;
|
||||||
if (!ScenePartitionUtils.TryGetScenePartitionSOForActiveScene(out scenePartitionSO)) return;
|
if (!ScenePartitionUtils.TryGetScenePartitionSOForActiveScene(out scenePartitionSO)) return;
|
||||||
|
|
||||||
|
int cellSize = scenePartitionSO.Data.SceneGrid.cellSize;
|
||||||
Vector3 gridPosition = CalculateGridPosition(Event.current.mousePosition);
|
Vector3 gridPosition = CalculateGridPosition(Event.current.mousePosition);
|
||||||
int gridId = SceneGrid.CalculateGridPosition(gridPosition, cellSize);
|
int gridId = SceneGrid.CalculateGridPosition(gridPosition, cellSize);
|
||||||
|
|
||||||
|
@ -5,12 +5,15 @@ namespace VertexColor.ScenePartition
|
|||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class SceneGrid
|
public class SceneGrid
|
||||||
{
|
{
|
||||||
|
[SerializeField]
|
||||||
|
public int cellSize = 10;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private SceneGridDictionary grid = new SceneGridDictionary();
|
private SceneGridDictionary grid = new SceneGridDictionary();
|
||||||
|
|
||||||
public SceneGridDictionary Grid => grid;
|
public SceneGridDictionary Grid => grid;
|
||||||
|
|
||||||
public void Insert(ulong scenePartitionId, Vector3 point, int cellSize)
|
public void Insert(ulong scenePartitionId, Vector3 point)
|
||||||
{
|
{
|
||||||
int gridId = CalculateGridPosition(point, cellSize);
|
int gridId = CalculateGridPosition(point, cellSize);
|
||||||
if (grid.TryGetValue(gridId, out GridList ids))
|
if (grid.TryGetValue(gridId, out GridList ids))
|
||||||
|
Loading…
Reference in New Issue
Block a user