From 5dae16ff4d5160811adc53b5c3624628c041cf29 Mon Sep 17 00:00:00 2001 From: Techanon <1837484+techanon@users.noreply.github.com> Date: Sun, 22 Dec 2024 17:05:51 -0600 Subject: [PATCH] Make use of FindObjectsByType consistent. (#328) * Make use of FindObjectsByType consistent. Anything beyond 2021.3 supports the ByType API. * Update AudioLinkEditor.cs --------- Co-authored-by: hill --- .../Editor/Scripts/AudioLinkEditor.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Packages/com.llealloo.audiolink/Editor/Scripts/AudioLinkEditor.cs b/Packages/com.llealloo.audiolink/Editor/Scripts/AudioLinkEditor.cs index f30a0841..666aa0a7 100644 --- a/Packages/com.llealloo.audiolink/Editor/Scripts/AudioLinkEditor.cs +++ b/Packages/com.llealloo.audiolink/Editor/Scripts/AudioLinkEditor.cs @@ -2,9 +2,8 @@ using System.Reflection; #if UDONSHARP -using UdonSharp; using UdonSharpEditor; -using BehaviourType = UdonSharpBehaviour; +using BehaviourType = UdonSharp.UdonSharpBehaviour; #else using BehaviourType = MonoBehaviour; #endif @@ -88,11 +87,12 @@ public void LinkAll() public static void LinkAll(AudioLink target) { BehaviourType[] allBehaviours = FindObjectsByType( -#if UNITY_6000_0_OR_NEWER +#if UNITY_2021_3_OR_NEWER FindObjectsInactive.Include, FindObjectsSortMode.InstanceID -#endif +#else + true +#endif ); - // this handles all reasonable cases of referencing audiolink // (it doesn't handle referencing it multiple times in one monobehaviour, or referencing it as it's Base type) foreach (BehaviourType behaviour in allBehaviours) @@ -110,6 +110,7 @@ public static void LinkAll(AudioLink target) } } } + if (fieldInfo != null && fieldInfo.FieldType == typeof(AudioLink)) { fieldInfo.SetValue(behaviour, target);