diff --git a/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/MainThreadDispatcher.cs b/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/MainThreadDispatcher.cs index 91cc8c45..baf26d2b 100644 --- a/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/MainThreadDispatcher.cs +++ b/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/MainThreadDispatcher.cs @@ -449,7 +449,11 @@ public static void Initialize() try { +#if UNITY_2020_3_OR_NEWER + dispatcher = GameObject.FindAnyObjectByType(); +#else dispatcher = GameObject.FindObjectOfType(); +#endif } catch { @@ -577,7 +581,11 @@ static void DestroyDispatcher(MainThreadDispatcher aDispatcher) public static void CullAllExcessDispatchers() { +#if UNITY_2020_3_OR_NEWER + var dispatchers = GameObject.FindObjectsByType(FindObjectsSortMode.None); +#else var dispatchers = GameObject.FindObjectsOfType(); +#endif for (int i = 0; i < dispatchers.Length; i++) { DestroyDispatcher(dispatchers[i]); @@ -588,7 +596,11 @@ void OnDestroy() { if (instance == this) { +#if UNITY_2020_3_OR_NEWER + instance = GameObject.FindAnyObjectByType(); +#else instance = GameObject.FindObjectOfType(); +#endif initialized = instance != null; /* diff --git a/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs b/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs index 9ec1c545..af1785d5 100644 --- a/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs +++ b/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs @@ -169,6 +169,7 @@ static void BuildTargetStandaloneWindows64() SaveSettings(settings); } +#if !UNITY_2019_2_OR_NEWER [MenuItem("Test/Settings/BuildTarget/StandaloneLinux", validate = true, priority = 3)] static bool ValidateBuildTargetStandaloneLinux() { @@ -184,6 +185,7 @@ static void BuildTargetStandaloneLinux() settings.BuildTarget = BuildTarget.StandaloneLinux; SaveSettings(settings); } +#endif [MenuItem("Test/Settings/BuildTarget/StandaloneLinux64", validate = true, priority = 4)] static bool ValidateBuildTargetStandaloneLinux64() diff --git a/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs b/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs index 8ca10687..10095538 100644 --- a/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs +++ b/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs @@ -113,7 +113,11 @@ public static void BuildUnitTest() } if (settings.UseCurrentScriptBackend) { +#if UNITY_2021_2_OR_NEWER + settings.ScriptBackend = PlayerSettings.GetScriptingBackend(UnityEditor.Build.NamedBuildTarget.FromBuildTargetGroup(ToBuildTargetGroup(settings.BuildTarget))); +#else settings.ScriptBackend = PlayerSettings.GetScriptingBackend(ToBuildTargetGroup(settings.BuildTarget)); +#endif } if (buildPath == null) @@ -386,17 +390,27 @@ static void Build(string sceneName, string buildPath, RuntimeUnitTestSettings se { options |= BuildOptions.AutoRunPlayer; } +#if !UNITY_2021_2_OR_NEWER if (settings.Headless) { options |= BuildOptions.EnableHeadlessMode; } +#endif var targetGroup = ToBuildTargetGroup(settings.BuildTarget); +#if UNITY_2021_2_OR_NEWER + var currentBackend = PlayerSettings.GetScriptingBackend(UnityEditor.Build.NamedBuildTarget.FromBuildTargetGroup(targetGroup)); +#else var currentBackend = PlayerSettings.GetScriptingBackend(targetGroup); +#endif if (currentBackend != settings.ScriptBackend) { UnityEngine.Debug.Log("Modify ScriptBackend to " + settings.ScriptBackend); +#if UNITY_2021_2_OR_NEWER + PlayerSettings.SetScriptingBackend(UnityEditor.Build.NamedBuildTarget.FromBuildTargetGroup(targetGroup), settings.ScriptBackend); +#else PlayerSettings.SetScriptingBackend(targetGroup, settings.ScriptBackend); +#endif } var buildOptions = new BuildPlayerOptions @@ -407,6 +421,12 @@ static void Build(string sceneName, string buildPath, RuntimeUnitTestSettings se scenes = new[] { sceneName }, locationPathName = buildPath }; +#if UNITY_2021_2_OR_NEWER + if (settings.Headless) + { + buildOptions.subtarget = (int)StandaloneBuildSubtarget.Server; + } +#endif UnityEngine.Debug.Log("UnitTest Build Start, " + settings.ToString()); @@ -415,7 +435,11 @@ static void Build(string sceneName, string buildPath, RuntimeUnitTestSettings se if (currentBackend != settings.ScriptBackend) { UnityEngine.Debug.Log("Restore ScriptBackend to " + currentBackend); +#if UNITY_2021_2_OR_NEWER + PlayerSettings.SetScriptingBackend(UnityEditor.Build.NamedBuildTarget.FromBuildTargetGroup(targetGroup), currentBackend); +#else PlayerSettings.SetScriptingBackend(targetGroup, currentBackend); +#endif } if (buildReport.summary.result != BuildResult.Succeeded)