using UnityEngine; namespace Pathfinding.Util { /// Compatibility class for Unity APIs that are not available in all Unity versions public static class UnityCompatibility { public static T[] FindObjectsByTypeSorted() where T : Object { #if UNITY_2021_3_OR_NEWER && !(UNITY_2022_1_OR_NEWER && !UNITY_2022_2_OR_NEWER) return Object.FindObjectsByType(FindObjectsSortMode.InstanceID); #else return Object.FindObjectsOfType(); #endif } public static T[] FindObjectsByTypeUnsorted() where T : Object { #if UNITY_2021_3_OR_NEWER && !(UNITY_2022_1_OR_NEWER && !UNITY_2022_2_OR_NEWER) return Object.FindObjectsByType(FindObjectsSortMode.None); #else return Object.FindObjectsOfType(); #endif } public static T[] FindObjectsByTypeUnsortedWithInactive() where T : Object { #if UNITY_2021_3_OR_NEWER && !(UNITY_2022_1_OR_NEWER && !UNITY_2022_2_OR_NEWER) return Object.FindObjectsByType(FindObjectsInactive.Include, FindObjectsSortMode.None); #else return Object.FindObjectsOfType(true); #endif } public static T FindAnyObjectByType() where T : Object { #if UNITY_2021_3_OR_NEWER && !(UNITY_2022_1_OR_NEWER && !UNITY_2022_2_OR_NEWER) return Object.FindAnyObjectByType(); #else return Object.FindObjectOfType(); #endif } } }