fix: #3262 allow running a mirror project from edit prefab mode again (#3924)

Co-authored-by: mischa <info@noobtuts.com>
This commit is contained in:
mischa 2024-10-28 23:13:23 +01:00 committed by GitHub
parent 68c7d14a16
commit c80a3c8ea5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;
}
}
}
}