generated from max/template-unity-project
	Update ScenePartitionEditorWindow.cs
- Draw scene partition in scene partition editor window
This commit is contained in:
		@@ -11,6 +11,9 @@ namespace VertexColor.ScenePartition.Editor
 | 
				
			|||||||
        private Vector2 scrollPos = Vector2.zero;
 | 
					        private Vector2 scrollPos = Vector2.zero;
 | 
				
			||||||
        private bool foldoutGroupEnabled = false;
 | 
					        private bool foldoutGroupEnabled = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private ulong id = 0;
 | 
				
			||||||
 | 
					        private int gridId = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [MenuItem("Window/ScenePartition")]
 | 
					        [MenuItem("Window/ScenePartition")]
 | 
				
			||||||
        public static void ShowExample()
 | 
					        public static void ShowExample()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@@ -19,6 +22,99 @@ namespace VertexColor.ScenePartition.Editor
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void OnGUI()
 | 
					        private void OnGUI()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            using (new EditorGUILayout.VerticalScope())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                DrawScenePartition();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                GUILayout.FlexibleSpace();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                DrawSceneDataCache();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void DrawScenePartition()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (!ScenePartitionUtils.TryGetScenePartitionSOForActiveScene(out var scenePartitionSO)) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            EditorGUILayout.LabelField($"ScenePartition | {scenePartitionSO.SceneName}", EditorStyles.boldLabel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (scenePartitionSO.SceneAsset == null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (GUILayout.Button("Create Scene"))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    scenePartitionSO.CreateScene();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                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();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                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"))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    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();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (GUILayout.Button("Open Scene Data Folder"))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    EditorUtility.RevealInFinder(ScenePartitionUtils.GetDataPath(scenePartitionSO));
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void DrawSceneDataCache()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            EditorGUILayout.LabelField("Cache", EditorStyles.boldLabel);
 | 
					            EditorGUILayout.LabelField("Cache", EditorStyles.boldLabel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -37,11 +133,6 @@ namespace VertexColor.ScenePartition.Editor
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            EditorGUIUtils.HorizontalLine();
 | 
					            EditorGUIUtils.HorizontalLine();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            DrawSceneDataCache();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private void DrawSceneDataCache()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            using (EditorGUIUtils.FoldoutHeaderScope foldoutGroup = new EditorGUIUtils.FoldoutHeaderScope("SceneDataCache", ref foldoutGroupEnabled))
 | 
					            using (EditorGUIUtils.FoldoutHeaderScope foldoutGroup = new EditorGUIUtils.FoldoutHeaderScope("SceneDataCache", ref foldoutGroupEnabled))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (!foldoutGroupEnabled) return;
 | 
					                if (!foldoutGroupEnabled) return;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user