From 8722a9920c1f6119bf6e769cba270e63097f8e25 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Thu, 23 May 2024 10:08:29 +0800 Subject: + astar project --- .../Core/Misc/UnityCompatibility.cs | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Core/Misc/UnityCompatibility.cs (limited to 'Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Core/Misc/UnityCompatibility.cs') diff --git a/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Core/Misc/UnityCompatibility.cs b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Core/Misc/UnityCompatibility.cs new file mode 100644 index 0000000..6fdd1e6 --- /dev/null +++ b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Core/Misc/UnityCompatibility.cs @@ -0,0 +1,38 @@ +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 + } + } +} -- cgit v1.1-26-g67d0