mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
* fix #1407: Check EnterPlayModeSettings and disable if needed for 2019.3 support * add reference
This commit is contained in:
parent
a3ffd1264c
commit
651e709785
46
Assets/Mirror/Editor/EnterPlayModeSettingsCheck.cs
Normal file
46
Assets/Mirror/Editor/EnterPlayModeSettingsCheck.cs
Normal 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
|
||||
}
|
||||
}
|
11
Assets/Mirror/Editor/EnterPlayModeSettingsCheck.cs.meta
Normal file
11
Assets/Mirror/Editor/EnterPlayModeSettingsCheck.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b15a0d2ca0909400eb53dd6fe894cddd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user