diff --git a/modules/juce_audio_plugin_client/detail/juce_PluginUtilities.h b/modules/juce_audio_plugin_client/detail/juce_PluginUtilities.h index 762261174f..de2f5f6d7b 100644 --- a/modules/juce_audio_plugin_client/detail/juce_PluginUtilities.h +++ b/modules/juce_audio_plugin_client/detail/juce_PluginUtilities.h @@ -30,13 +30,6 @@ namespace juce::detail { -bool isRunningInUnity(); -#if JucePlugin_Build_Unity -bool isRunningInUnity() { return PluginHostType::getPluginLoadedAs() == AudioProcessor::wrapperType_Unity; } -#else -bool isRunningInUnity() { return false; } -#endif - struct PluginUtilities { PluginUtilities() = delete; diff --git a/modules/juce_audio_plugin_client/juce_audio_plugin_client_Unity.cpp b/modules/juce_audio_plugin_client/juce_audio_plugin_client_Unity.cpp index c624322712..aee1f4d36c 100644 --- a/modules/juce_audio_plugin_client/juce_audio_plugin_client_Unity.cpp +++ b/modules/juce_audio_plugin_client/juce_audio_plugin_client_Unity.cpp @@ -36,6 +36,8 @@ #include +#include + //============================================================================== namespace juce { @@ -292,6 +294,7 @@ class AudioProcessorUnityWrapper public: AudioProcessorUnityWrapper (bool isTemporary) { + detail::RunningInUnity::state = true; pluginInstance = createPluginFilterOfType (AudioProcessor::wrapperType_Unity); if (! isTemporary && pluginInstance->hasEditor()) diff --git a/modules/juce_events/juce_events.cpp b/modules/juce_events/juce_events.cpp index c6678d5d28..cb6238a067 100644 --- a/modules/juce_events/juce_events.cpp +++ b/modules/juce_events/juce_events.cpp @@ -81,6 +81,7 @@ #endif #elif JUCE_WINDOWS + #include "native/juce_RunningInUnity.h" #include "native/juce_win32_Messaging.cpp" #if JUCE_EVENTS_INCLUDE_WINRT_WRAPPER #include "native/juce_win32_WinRTWrapper.cpp" diff --git a/modules/juce_events/native/juce_RunningInUnity.h b/modules/juce_events/native/juce_RunningInUnity.h new file mode 100644 index 0000000000..6a96cf8a36 --- /dev/null +++ b/modules/juce_events/native/juce_RunningInUnity.h @@ -0,0 +1,35 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + The code included in this file is provided under the terms of the ISC license + http://www.isc.org/downloads/software-support-policy/isc-license. Permission + To use, copy, modify, and/or distribute this software for any purpose with or + without fee is hereby granted provided that the above copyright notice and + this permission notice appear in all copies. + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +#pragma once + +namespace juce::detail +{ + +class RunningInUnity +{ +public: + /* @internal */ + static inline bool state = false; +}; + +} // namespace juce::detail diff --git a/modules/juce_events/native/juce_win32_Messaging.cpp b/modules/juce_events/native/juce_win32_Messaging.cpp index b918b5610f..e011373b95 100644 --- a/modules/juce_events/native/juce_win32_Messaging.cpp +++ b/modules/juce_events/native/juce_win32_Messaging.cpp @@ -25,15 +25,6 @@ namespace juce extern HWND juce_messageWindowHandle; -namespace detail -{ - #if JUCE_MODULE_AVAILABLE_juce_audio_plugin_client - bool isRunningInUnity(); - #else - constexpr bool isRunningInUnity() { return false; } - #endif -} // namespace detail - #if JUCE_MODULE_AVAILABLE_juce_gui_extra LRESULT juce_offerEventToActiveXControl (::MSG&); #endif @@ -99,7 +90,7 @@ public: if (! shouldTriggerMessageQueueDispatch) return; - if (detail::isRunningInUnity()) + if (detail::RunningInUnity::state) { SendNotifyMessage (juce_messageWindowHandle, customMessageID, 0, 0); return;