public override void OnInspectorGUI() { var subScene = target as SubScene; var prevSceneAsset = subScene.SceneAsset; var prevColor = subScene.HierarchyColor; base.OnInspectorGUI(); if (subScene.SceneAsset != prevSceneAsset || subScene.HierarchyColor != prevColor) { SceneHierarchyHooks.ReloadAllSceneHierarchies(); } var targetsArray = targets; var subscenes = new SubScene[targetsArray.Length]; targetsArray.CopyTo(subscenes, 0); EditorGUILayout.TextArea("", GUI.skin.horizontalSlider); GUILayout.BeginHorizontal(); if (!SubSceneInspectorUtility.IsEditingAll(subscenes)) { GUI.enabled = SubSceneInspectorUtility.CanEditScene(subscenes); if (GUILayout.Button("Edit")) { SubSceneInspectorUtility.EditScene(subscenes); } } else { GUI.enabled = true; if (GUILayout.Button("Close")) { SubSceneInspectorUtility.CloseAndAskSaveIfUserWantsTo(subscenes); } } GUI.enabled = SubSceneInspectorUtility.IsDirty(subscenes); if (GUILayout.Button("Save")) { SubSceneInspectorUtility.SaveScene(subscenes); } GUI.enabled = true; GUILayout.EndHorizontal(); var scenes = SubSceneInspectorUtility.GetLoadableScenes(subscenes); EditorGUILayout.TextArea("", GUI.skin.horizontalSlider); GUILayout.Space(10); if (World.DefaultGameObjectInjectionWorld != null) { var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager; foreach (var scene in scenes) { if (!entityManager.HasComponent <RequestSceneLoaded>(scene.Scene)) { if (GUILayout.Button($"Load '{scene.Name}'")) { entityManager.AddComponentData(scene.Scene, new RequestSceneLoaded()); EditorUpdateUtility.EditModeQueuePlayerLoopUpdate(); } } else { if (GUILayout.Button($"Unload '{scene.Name}'")) { entityManager.RemoveComponent <RequestSceneLoaded>(scene.Scene); EditorUpdateUtility.EditModeQueuePlayerLoopUpdate(); } } } } #if false // @TODO: TEMP for debugging if (GUILayout.Button("ClearWorld")) { World.DisposeAllWorlds(); DefaultWorldInitialization.Initialize("Default World", !Application.isPlaying); var scenes = FindObjectsOfType <SubScene>(); foreach (var scene in scenes) { var oldEnabled = scene.enabled; scene.enabled = false; scene.enabled = oldEnabled; } EditorUpdateUtility.EditModeQueuePlayerLoopUpdate(); } #endif var uncleanHierarchyObject = SubSceneInspectorUtility.GetUncleanHierarchyObject(subscenes); if (uncleanHierarchyObject != null) { EditorGUILayout.HelpBox($"Scene transform values are not applied to scenes child transforms. But {uncleanHierarchyObject.name} has an offset Transform.", MessageType.Warning, true); if (GUILayout.Button("Clear")) { foreach (var scene in subscenes) { scene.transform.localPosition = Vector3.zero; scene.transform.localRotation = Quaternion.identity; scene.transform.localScale = Vector3.one; } } } if (SubSceneInspectorUtility.HasChildren(subscenes)) { EditorGUILayout.HelpBox($"SubScenes can not have child game objects. Close the scene and delete the child game objects.", MessageType.Warning, true); } if (CheckConversionLog(subScene)) { GUILayout.Space(10); GUILayout.Label("Importing..."); Repaint(); } if (m_ConversionLog.Length != 0) { GUILayout.Space(10); GUILayout.Label("Conversion Log"); GUILayout.TextArea(m_ConversionLog); } }
public override void OnInspectorGUI() { var subScene = target as SubScene; if (!subScene.IsInMainStage()) { // In Prefab Mode and when selecting a Prefab Asset in the Project Browser we only show the inspector of data of the // SubScene, and not the load/unload/edit/close buttons. base.OnInspectorGUI(); EditorGUILayout.HelpBox($"Only Sub Scenes in the Main Stage can be loaded and unloaded.", MessageType.Info, true); EditorGUILayout.Space(); return; } var prevColor = subScene.HierarchyColor; CachePreviousSceneAssetReferences(); base.OnInspectorGUI(); HandleChangedSceneAssetReferences(); if (subScene.HierarchyColor != prevColor) { SceneHierarchyHooks.ReloadAllSceneHierarchies(); } var targetsArray = targets; var subscenes = new SubScene[targetsArray.Length]; targetsArray.CopyTo(subscenes, 0); GUILayout.BeginHorizontal(); if (!SubSceneInspectorUtility.IsEditingAll(subscenes)) { GUI.enabled = SubSceneInspectorUtility.CanEditScene(subscenes); if (GUILayout.Button("Edit")) { SubSceneInspectorUtility.EditScene(subscenes); } } else { GUI.enabled = true; if (GUILayout.Button("Close")) { SubSceneInspectorUtility.CloseAndAskSaveIfUserWantsTo(subscenes); } } GUI.enabled = SubSceneInspectorUtility.IsDirty(subscenes); if (GUILayout.Button("Save")) { SubSceneInspectorUtility.SaveScene(subscenes); } GUI.enabled = true; GUILayout.EndHorizontal(); var scenes = SubSceneInspectorUtility.GetLoadableScenes(subscenes); GUILayout.Space(10); if (World.DefaultGameObjectInjectionWorld != null) { var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager; foreach (var scene in scenes) { if (!entityManager.HasComponent <RequestSceneLoaded>(scene.Scene)) { if (GUILayout.Button($"Load '{scene.Name}'")) { entityManager.AddComponentData(scene.Scene, new RequestSceneLoaded()); EditorUpdateUtility.EditModeQueuePlayerLoopUpdate(); } } else { if (GUILayout.Button($"Unload '{scene.Name}'")) { entityManager.RemoveComponent <RequestSceneLoaded>(scene.Scene); EditorUpdateUtility.EditModeQueuePlayerLoopUpdate(); } } } } #if false // @TODO: TEMP for debugging if (GUILayout.Button("ClearWorld")) { World.DisposeAllWorlds(); DefaultWorldInitialization.Initialize("Default World", !Application.isPlaying); var scenes = FindObjectsOfType <SubScene>(); foreach (var scene in scenes) { var oldEnabled = scene.enabled; scene.enabled = false; scene.enabled = oldEnabled; } EditorUpdateUtility.EditModeQueuePlayerLoopUpdate(); } #endif bool hasDuplicates = subScene.SceneAsset != null && (SubScene.AllSubScenes.Count(s => (s.SceneAsset == subScene.SceneAsset)) > 1); if (hasDuplicates) { EditorGUILayout.HelpBox($"The Scene Asset '{subScene.EditableScenePath}' is used mutiple times and this is not supported. Clear the reference.", MessageType.Warning, true); if (GUILayout.Button("Clear")) { subScene.SceneAsset = null; SceneHierarchyHooks.ReloadAllSceneHierarchies(); } EditorGUILayout.Space(); } var uncleanHierarchyObject = SubSceneInspectorUtility.GetUncleanHierarchyObject(subscenes); if (uncleanHierarchyObject != null) { EditorGUILayout.HelpBox($"Scene transform values are not applied to scenes child transforms. But {uncleanHierarchyObject.name} has an offset Transform.", MessageType.Warning, true); if (GUILayout.Button("Clear")) { foreach (var scene in subscenes) { scene.transform.localPosition = Vector3.zero; scene.transform.localRotation = Quaternion.identity; scene.transform.localScale = Vector3.one; } } EditorGUILayout.Space(); } if (SubSceneInspectorUtility.HasChildren(subscenes)) { EditorGUILayout.HelpBox($"SubScenes can not have child game objects. Close the scene and delete the child game objects.", MessageType.Warning, true); } GUILayout.Space(10); if (CheckConversionLog(subScene)) { GUILayout.Label("Importing..."); Repaint(); } else { if (!SubSceneInspectorUtility.IsEditingAll(subscenes)) { if (GUILayout.Button("Reimport")) { SubSceneInspectorUtility.ForceReimport(subscenes); } } } if (m_ConversionLog.Length != 0) { GUILayout.Space(10); GUILayout.Label("Conversion Log"); GUILayout.TextArea(m_ConversionLog); } }
public override void OnInspectorGUI() { var subScene = target as SubScene; if (!subScene.IsInMainStage()) { // In Prefab Mode and when selecting a Prefab Asset in the Project Browser we only show the inspector of data of the // SubScene, and not the load/unload/edit/close buttons. base.OnInspectorGUI(); EditorGUILayout.HelpBox($"Only Sub Scenes in the Main Stage can be loaded and unloaded.", MessageType.Info, true); EditorGUILayout.Space(); return; } var prevColor = subScene.HierarchyColor; CachePreviousSceneAssetReferences(); base.OnInspectorGUI(); HandleChangedSceneAssetReferences(); if (subScene.HierarchyColor != prevColor) { SceneHierarchyHooks.ReloadAllSceneHierarchies(); } DrawOpenSubScenes(_selectedSubscenes); var loadableScenes = SubSceneInspectorUtility.GetLoadableScenes(_selectedSubscenes); if (DrawClosedSubScenes(loadableScenes, _selectedSubscenes)) { Repaint(); } #if false // @TODO: TEMP for debugging if (GUILayout.Button("ClearWorld")) { World.DisposeAllWorlds(); DefaultWorldInitialization.Initialize("Default World", !Application.isPlaying); var scenes = FindObjectsOfType <SubScene>(); foreach (var scene in scenes) { var oldEnabled = scene.enabled; scene.enabled = false; scene.enabled = oldEnabled; } EditorUpdateUtility.EditModeQueuePlayerLoopUpdate(); } #endif bool hasDuplicates = subScene.SceneAsset != null && (SubScene.AllSubScenes.Count(s => (s.SceneAsset == subScene.SceneAsset)) > 1); if (hasDuplicates) { EditorGUILayout.HelpBox($"The Scene Asset '{subScene.EditableScenePath}' is used mutiple times and this is not supported. Clear the reference.", MessageType.Warning, true); if (GUILayout.Button("Clear")) { subScene.SceneAsset = null; SceneHierarchyHooks.ReloadAllSceneHierarchies(); } EditorGUILayout.Space(); } var uncleanHierarchyObject = SubSceneInspectorUtility.GetUncleanHierarchyObject(_selectedSubscenes); if (uncleanHierarchyObject != null) { EditorGUILayout.HelpBox($"Scene transform values are not applied to scenes child transforms. But {uncleanHierarchyObject.name} has an offset Transform.", MessageType.Warning, true); if (GUILayout.Button("Clear")) { foreach (var scene in _selectedSubscenes) { scene.transform.localPosition = Vector3.zero; scene.transform.localRotation = Quaternion.identity; scene.transform.localScale = Vector3.one; } } EditorGUILayout.Space(); } if (SubSceneInspectorUtility.HasChildren(_selectedSubscenes)) { EditorGUILayout.HelpBox($"SubScenes can not have child game objects. Close the scene and delete the child game objects.", MessageType.Warning, true); } if (targets.Length == 1) { GUILayout.Space(EditorGUIUtility.singleLineHeight); if (CheckConversionLog(subScene)) { GUILayout.Label("Importing..."); Repaint(); } if (m_ConversionLog.Length != 0) { GUILayout.Space(EditorGUIUtility.singleLineHeight); GUILayout.Label("Conversion Log", EditorStyles.boldLabel); GUILayout.TextArea(m_ConversionLog); } } }