Fixed bug where Unity would call libpd functions when no patch was loaded, causing a crash in Unity 2021.1.
This commit is contained in:
parent
12dc67bb75
commit
4c17055789
2 changed files with 16 additions and 11 deletions
|
|
@ -448,6 +448,8 @@ public class LibPdInstance : MonoBehaviour
|
|||
private bool pdFail = false;
|
||||
/// True if we were unable to open our patch.
|
||||
private bool patchFail = false;
|
||||
/// True if we have successfully loaded our patch.
|
||||
private bool loaded = false;
|
||||
|
||||
/// Global variable used to ensure we don't initialise LibPd more than once.
|
||||
private static bool pdInitialised = false;
|
||||
|
|
@ -613,6 +615,9 @@ public class LibPdInstance : MonoBehaviour
|
|||
libpd_start_message(1);
|
||||
libpd_add_float(1.0f);
|
||||
libpd_finish_message("pd", "dsp");
|
||||
|
||||
if(!patchFail)
|
||||
loaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -621,7 +626,7 @@ public class LibPdInstance : MonoBehaviour
|
|||
/// We only add ourselves to activeInstances when we're enabled.
|
||||
void OnEnable()
|
||||
{
|
||||
if(!pdFail && !patchFail)
|
||||
if(!pdFail && !patchFail && loaded)
|
||||
activeInstances.Add(this);
|
||||
}
|
||||
|
||||
|
|
@ -636,7 +641,7 @@ public class LibPdInstance : MonoBehaviour
|
|||
/// Close the patch file on quit.
|
||||
void OnDestroy()
|
||||
{
|
||||
if(!pdFail && !patchFail)
|
||||
if(!pdFail && !patchFail && loaded)
|
||||
{
|
||||
libpd_set_instance(instance);
|
||||
|
||||
|
|
@ -731,7 +736,7 @@ public class LibPdInstance : MonoBehaviour
|
|||
/// Process audio.
|
||||
void OnAudioFilterRead(float[] data, int channels)
|
||||
{
|
||||
if(!pdFail && !patchFail)
|
||||
if(!pdFail && !patchFail && loaded)
|
||||
{
|
||||
libpd_set_instance(instance);
|
||||
libpd_process_float(numTicks, data, data);
|
||||
|
|
|
|||
|
|
@ -3,25 +3,25 @@
|
|||
--- !u!310 &1
|
||||
UnityConnectSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
m_Enabled: 0
|
||||
serializedVersion: 1
|
||||
m_Enabled: 1
|
||||
m_TestMode: 0
|
||||
m_TestEventUrl:
|
||||
m_TestConfigUrl:
|
||||
m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events
|
||||
m_EventUrl: https://cdp.cloud.unity3d.com/v1/events
|
||||
m_ConfigUrl: https://config.uca.cloud.unity3d.com
|
||||
m_TestInitMode: 0
|
||||
CrashReportingSettings:
|
||||
m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes
|
||||
m_NativeEventUrl: https://perf-events.cloud.unity3d.com/symbolicate
|
||||
m_EventUrl: https://perf-events.cloud.unity3d.com
|
||||
m_Enabled: 0
|
||||
m_LogBufferSize: 10
|
||||
m_CaptureEditorExceptions: 1
|
||||
UnityPurchasingSettings:
|
||||
m_Enabled: 0
|
||||
m_TestMode: 0
|
||||
UnityAnalyticsSettings:
|
||||
m_Enabled: 1
|
||||
m_InitializeOnStartup: 1
|
||||
m_TestMode: 0
|
||||
m_TestEventUrl:
|
||||
m_TestConfigUrl:
|
||||
m_InitializeOnStartup: 1
|
||||
UnityAdsSettings:
|
||||
m_Enabled: 0
|
||||
m_InitializeOnStartup: 1
|
||||
|
|
|
|||
Loading…
Reference in a new issue