From c80a3c8ea57effd1ce154d3f336bcbb432496094 Mon Sep 17 00:00:00 2001 From: mischa <16416509+miwarnec@users.noreply.github.com> Date: Mon, 28 Oct 2024 23:13:23 +0100 Subject: [PATCH] fix: #3262 allow running a mirror project from edit prefab mode again (#3924) Co-authored-by: mischa --- .../Mirror/Editor/NetworkScenePostProcess.cs | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/Assets/Mirror/Editor/NetworkScenePostProcess.cs b/Assets/Mirror/Editor/NetworkScenePostProcess.cs index 2fa07d65b..9baad1b90 100644 --- a/Assets/Mirror/Editor/NetworkScenePostProcess.cs +++ b/Assets/Mirror/Editor/NetworkScenePostProcess.cs @@ -55,19 +55,28 @@ public static void OnPostProcessScene() else { // there are two cases where sceneId == 0: - // * if we have a prefab open in the prefab scene - // * if an unopened scene needs resaving - // show a proper error message in both cases so the user - // knows what to do. + // if we have a prefab open in the prefab scene string path = identity.gameObject.scene.path; if (string.IsNullOrWhiteSpace(path)) + { + // pressing play while in prefab edit mode used to freeze/crash Unity 2019. + // this seems fine now so we don't need to stop the editor anymore. +#if UNITY_2020_3_OR_NEWER + Debug.LogWarning($"{identity.name} was open in Prefab Edit Mode while launching with Mirror. If this causes issues, please let us know."); +#else Debug.LogError($"{identity.name} is currently open in Prefab Edit Mode. Please open the actual scene before launching Mirror."); + EditorApplication.isPlaying = false; +#endif + } + // if an unopened scene needs resaving else - Debug.LogError($"Scene {path} needs to be opened and resaved, because the scene object {identity.name} has no valid sceneId yet."); + { - // either way we shouldn't continue. nothing good will - // happen when trying to launch with invalid sceneIds. - EditorApplication.isPlaying = false; + // nothing good will happen when trying to launch with invalid sceneIds. + // show an error and stop playing immediately. + Debug.LogError($"Scene {path} needs to be opened and resaved, because the scene object {identity.name} has no valid sceneId yet."); + EditorApplication.isPlaying = false; + } } } }