From e8443fa972270b05e35973239f17711f7fa6b2ee Mon Sep 17 00:00:00 2001 From: Pema Malling Date: Tue, 12 Dec 2023 22:48:55 +0100 Subject: [PATCH] Any public API that uses cached shader property IDs MUST initialize those IDs. We can't know when these are called externally. In particular, they may be called before the AudioLink script has even been initialized, like in the Start method of a separate behavior. Initializing twice is a no-op, so there should be no perf issues here. --- Packages/com.llealloo.audiolink/Runtime/Scripts/AudioLink.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Packages/com.llealloo.audiolink/Runtime/Scripts/AudioLink.cs b/Packages/com.llealloo.audiolink/Runtime/Scripts/AudioLink.cs index 81b6b611..e7e46c0b 100644 --- a/Packages/com.llealloo.audiolink/Runtime/Scripts/AudioLink.cs +++ b/Packages/com.llealloo.audiolink/Runtime/Scripts/AudioLink.cs @@ -590,6 +590,7 @@ private void OnDisable() public void UpdateSettings() { + InitIDs(); audioMaterial.SetFloat(_Gain, gain); audioMaterial.SetFloat(_FadeLength, fadeLength); audioMaterial.SetFloat(_FadeExpFalloff, fadeExpFalloff); @@ -611,6 +612,7 @@ public void UpdateSettings() // rather than bundled in with the other things in UpdateSettings(). public void UpdateThemeColors() { + InitIDs(); audioMaterial.SetInt(_ThemeColorMode, themeColorMode); audioMaterial.SetColor(_CustomThemeColor0, customThemeColor0); audioMaterial.SetColor(_CustomThemeColor1, customThemeColor1); @@ -689,6 +691,7 @@ public override void OnDeserialization() private void UpdateGlobalString(int nameID, string input) { + InitIDs(); const int maxLength = 32; if (input.Length > maxLength) input = input.Substring(0, maxLength); @@ -755,6 +758,7 @@ public void DisableReadback() public void SendAudioOutputData() { + InitIDs(); audioSource.GetOutputData(_audioFramesL, 0); // left channel if (_rightChannelTestCounter > 0)