Skip to content

Commit

Permalink
fix: #3262 allow running a mirror project from edit prefab mode again (
Browse files Browse the repository at this point in the history
…#3924)

Co-authored-by: mischa <info@noobtuts.com>
  • Loading branch information
miwarnec and mischa authored Oct 28, 2024
1 parent 68c7d14 commit c80a3c8
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions Assets/Mirror/Editor/NetworkScenePostProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
Expand Down

0 comments on commit c80a3c8

Please sign in to comment.