Unity-Technologies / com.unity.netcode.gameobjects

Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.
MIT License
2.15k stars 435 forks source link

NetworkManager Attempts to use MarkSceneDirty in Playmode Testing #842

Closed dyburke closed 3 years ago

dyburke commented 3 years ago

Describe the bug Code in question here:

https://github.com/Unity-Technologies/com.unity.multiplayer.mlapi/blob/023b64aeecaeee7461bdf989000ff9a796cfde1b/com.unity.multiplayer.mlapi/Runtime/Core/NetworkManager.cs#L217-L223

This is what I did to fix:

#if UNITY_EDITOR
                if (!EditorApplication.isPlayingOrWillChangePlaymode)
                {
                    UnityEditor.EditorApplication.delayCall += () =>
                    {
                        UnityEditor.EditorUtility.SetDirty(this);
                        UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(activeScene);
                    };
                }
#endif

To Reproduce Steps to reproduce the behavior:

  1. Create a scene with a NetworkManager in it.
  2. Run a Playmode Test

Actual outcome An exception is thrown saying MarkSceneDirty cannot be used in play mode.

Expected outcome MarkSceneDirty should be avoided when in playmode.

Environment (please complete the following information):

dyburke commented 3 years ago

Now seeing this is already addressed in the develop branch. Closing issue.