From 39d13791edb4767459a79648256eabf20c7a3497 Mon Sep 17 00:00:00 2001 From: Jack Kelly Date: Wed, 1 Jan 2025 13:33:24 +0000 Subject: [PATCH 1/2] Corrected obsolete calls to Unity Object.FindObjectOfType() and Object.Object.FindObjectsOfType<>() --- .../Scripts/Runtime/SteamAudioBakedListener.cs | 10 +++++++++- .../Scripts/Runtime/SteamAudioBakedSource.cs | 12 ++++++++++-- .../Scripts/Runtime/UnityAudioEngineState.cs | 4 ++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/unity/src/project/SteamAudioUnity/Assets/Plugins/SteamAudio/Scripts/Runtime/SteamAudioBakedListener.cs b/unity/src/project/SteamAudioUnity/Assets/Plugins/SteamAudio/Scripts/Runtime/SteamAudioBakedListener.cs index dd797c0d..6d013e91 100644 --- a/unity/src/project/SteamAudioUnity/Assets/Plugins/SteamAudio/Scripts/Runtime/SteamAudioBakedListener.cs +++ b/unity/src/project/SteamAudioUnity/Assets/Plugins/SteamAudio/Scripts/Runtime/SteamAudioBakedListener.cs @@ -124,7 +124,11 @@ public void BeginBake() tasks[0].component = this; tasks[0].name = gameObject.name; tasks[0].identifier = mIdentifier; +#if UNITY_2020_3_OR_NEWER + tasks[0].probeBatches = (useAllProbeBatches) ? FindObjectsByType(FindObjectsSortMode.None) : probeBatches; +#else tasks[0].probeBatches = (useAllProbeBatches) ? FindObjectsOfType() : probeBatches; +#endif tasks[0].probeBatchNames = new string[tasks[0].probeBatches.Length]; tasks[0].probeBatchAssets = new SerializedData[tasks[0].probeBatches.Length]; for (var i = 0; i < tasks[0].probeBatchNames.Length; ++i) @@ -143,8 +147,12 @@ void CacheIdentifier() void CacheProbeBatchesUsed() { +#if UNITY_2020_3_OR_NEWER + mProbeBatchesUsed = (useAllProbeBatches) ? FindObjectsByType(FindObjectsSortMode.None) : probeBatches; +#else mProbeBatchesUsed = (useAllProbeBatches) ? FindObjectsOfType() : probeBatches; +#endif } #endif - } + } } \ No newline at end of file diff --git a/unity/src/project/SteamAudioUnity/Assets/Plugins/SteamAudio/Scripts/Runtime/SteamAudioBakedSource.cs b/unity/src/project/SteamAudioUnity/Assets/Plugins/SteamAudio/Scripts/Runtime/SteamAudioBakedSource.cs index 8b0f38a9..fb4d8cd6 100644 --- a/unity/src/project/SteamAudioUnity/Assets/Plugins/SteamAudio/Scripts/Runtime/SteamAudioBakedSource.cs +++ b/unity/src/project/SteamAudioUnity/Assets/Plugins/SteamAudio/Scripts/Runtime/SteamAudioBakedSource.cs @@ -124,7 +124,11 @@ public void BeginBake() tasks[0].component = this; tasks[0].name = gameObject.name; tasks[0].identifier = mIdentifier; - tasks[0].probeBatches = (useAllProbeBatches) ? FindObjectsOfType() : probeBatches; +#if UNITY_2020_3_OR_NEWER + tasks[0].probeBatches = (useAllProbeBatches) ? FindObjectsByType(FindObjectsSortMode.None) : probeBatches; +#else + tasks[0].probeBatches = (useAllProbeBatches) ? FindObjectsOfType() : probeBatches; +#endif tasks[0].probeBatchNames = new string[tasks[0].probeBatches.Length]; tasks[0].probeBatchAssets = new SerializedData[tasks[0].probeBatches.Length]; for (var i = 0; i < tasks[0].probeBatchNames.Length; ++i) @@ -143,8 +147,12 @@ void CacheIdentifier() void CacheProbeBatchesUsed() { +#if UNITY_2020_3_OR_NEWER + mProbeBatchesUsed = (useAllProbeBatches) ? FindObjectsByType(FindObjectsSortMode.None) : probeBatches; +#else mProbeBatchesUsed = (useAllProbeBatches) ? FindObjectsOfType() : probeBatches; +#endif } #endif - } + } } \ No newline at end of file diff --git a/unity/src/project/SteamAudioUnity/Assets/Plugins/SteamAudio/Scripts/Runtime/UnityAudioEngineState.cs b/unity/src/project/SteamAudioUnity/Assets/Plugins/SteamAudio/Scripts/Runtime/UnityAudioEngineState.cs index 2b00ef90..7cfee921 100644 --- a/unity/src/project/SteamAudioUnity/Assets/Plugins/SteamAudio/Scripts/Runtime/UnityAudioEngineState.cs +++ b/unity/src/project/SteamAudioUnity/Assets/Plugins/SteamAudio/Scripts/Runtime/UnityAudioEngineState.cs @@ -62,7 +62,11 @@ public sealed class UnityAudioEngineStateHelpers : AudioEngineStateHelpers { public override Transform GetListenerTransform() { +#if UNITY_2023_3_OR_NEWER + var audioListener = GameObject.FindFirstObjectByType(); +#else var audioListener = GameObject.FindObjectOfType(); +#endif return (audioListener != null) ? audioListener.transform : null; } From 1b4c8b1c85f65938c9a149d2854f3dbb32919a0f Mon Sep 17 00:00:00 2001 From: Jack Kelly Date: Wed, 1 Jan 2025 15:03:58 +0000 Subject: [PATCH 2/2] Reverted an erroneous whitespace correction --- .../SteamAudio/Scripts/Runtime/SteamAudioBakedListener.cs | 2 +- .../Plugins/SteamAudio/Scripts/Runtime/SteamAudioBakedSource.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/unity/src/project/SteamAudioUnity/Assets/Plugins/SteamAudio/Scripts/Runtime/SteamAudioBakedListener.cs b/unity/src/project/SteamAudioUnity/Assets/Plugins/SteamAudio/Scripts/Runtime/SteamAudioBakedListener.cs index 6d013e91..cac4028e 100644 --- a/unity/src/project/SteamAudioUnity/Assets/Plugins/SteamAudio/Scripts/Runtime/SteamAudioBakedListener.cs +++ b/unity/src/project/SteamAudioUnity/Assets/Plugins/SteamAudio/Scripts/Runtime/SteamAudioBakedListener.cs @@ -154,5 +154,5 @@ void CacheProbeBatchesUsed() #endif } #endif - } + } } \ No newline at end of file diff --git a/unity/src/project/SteamAudioUnity/Assets/Plugins/SteamAudio/Scripts/Runtime/SteamAudioBakedSource.cs b/unity/src/project/SteamAudioUnity/Assets/Plugins/SteamAudio/Scripts/Runtime/SteamAudioBakedSource.cs index fb4d8cd6..68a59e5f 100644 --- a/unity/src/project/SteamAudioUnity/Assets/Plugins/SteamAudio/Scripts/Runtime/SteamAudioBakedSource.cs +++ b/unity/src/project/SteamAudioUnity/Assets/Plugins/SteamAudio/Scripts/Runtime/SteamAudioBakedSource.cs @@ -154,5 +154,5 @@ void CacheProbeBatchesUsed() #endif } #endif - } + } } \ No newline at end of file