fix #1407: Check EnterPlayModeSettings and disable if needed for 2019.3 support (#1415)

* fix #1407: Check EnterPlayModeSettings and disable if needed for 2019.3 support

* add reference
This commit is contained in:
vis2k 2020-01-09 08:03:47 +01:00 committed by GitHub
parent a3ffd1264c
commit 651e709785
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,46 @@
// Unity 2019.3 has an experimental 'disable domain reload on play'
// feature. keeping any global state between sessions will break
// Mirror and most of our user's projects. don't allow it for now.
// https://blogs.unity3d.com/2019/11/05/enter-play-mode-faster-in-unity-2019-3/
using UnityEditor;
using UnityEngine;
namespace Mirror
{
public class EnterPlayModeSettingsCheck : MonoBehaviour
{
#if UNITY_2019_3_OR_NEWER
[InitializeOnLoadMethod]
static void OnInitializeOnLoad()
{
// check immediately on load
CheckPlayModeOptions();
// check each time we press play. OnLoad is only called once and
// wouldn't detect editor-time setting changes
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
}
static void OnPlayModeStateChanged(PlayModeStateChange state)
{
// only check when entering play mode. no need to show it again
// when exiting.
if (state == PlayModeStateChange.EnteredPlayMode)
{
CheckPlayModeOptions();
}
}
static void CheckPlayModeOptions()
{
// enabling the checkbox is enough. it controls all the other
// settings.
if (EditorSettings.enterPlayModeOptionsEnabled)
{
Debug.LogError("Enter Play Mode Options are not supported by Mirror. Please disable 'ProjectSettings->Editor->Enter Play Mode Settings (Experimental)'.");
EditorApplication.isPlaying = false;
}
}
#endif
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b15a0d2ca0909400eb53dd6fe894cddd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: