summaryrefslogtreecommitdiff
path: root/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/PackageTools/Editor/DependencyCheck.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2024-05-23 10:08:29 +0800
committerchai <215380520@qq.com>2024-05-23 10:08:29 +0800
commit8722a9920c1f6119bf6e769cba270e63097f8e25 (patch)
tree2eaf9865de7fb1404546de4a4296553d8f68cc3b /Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/PackageTools/Editor/DependencyCheck.cs
parent3ba4020b69e5971bb0df7ee08b31d10ea4d01937 (diff)
+ astar project
Diffstat (limited to 'Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/PackageTools/Editor/DependencyCheck.cs')
-rw-r--r--Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/PackageTools/Editor/DependencyCheck.cs66
1 files changed, 66 insertions, 0 deletions
diff --git a/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/PackageTools/Editor/DependencyCheck.cs b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/PackageTools/Editor/DependencyCheck.cs
new file mode 100644
index 0000000..b7f2cb1
--- /dev/null
+++ b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/PackageTools/Editor/DependencyCheck.cs
@@ -0,0 +1,66 @@
+// Disable the warning: "Field 'DependencyCheck.Dependency.name' is never assigned to, and will always have its default value null"
+#pragma warning disable 649
+using UnityEditor;
+using System.Linq;
+using UnityEngine;
+
+namespace Pathfinding.Util {
+ [InitializeOnLoad]
+ static class DependencyCheck {
+ struct Dependency {
+ public string name;
+ public string version;
+ }
+
+ static DependencyCheck() {
+ var missingDependencies = new Dependency[] {
+#if !MODULE_BURST
+ new Dependency {
+ name = "com.unity.burst",
+ version = "1.8.3",
+ },
+#endif
+#if !MODULE_MATHEMATICS
+ new Dependency {
+ name = "com.unity.mathematics",
+ version = "1.2.6",
+ },
+#endif
+#if !MODULE_COLLECTIONS
+ new Dependency {
+ name = "com.unity.collections",
+ version = "1.5.1",
+ },
+#endif
+ // #if !MODULE_ENTITIES
+ // new Dependency {
+ // name = "com.unity.entities",
+ // version = "1.0.0-pre.47",
+ // },
+ // #endif
+ };
+
+ if (missingDependencies.Length > 0) {
+ string missing = string.Join(", ", missingDependencies.Select(p => p.name + " (" + p.version + ")"));
+ bool res = EditorUtility.DisplayDialog("Missing dependencies", "The packages " + missing + " are required by the A* Pathfinding Project but they are not installed, or the installed versions are too old. Do you want to install the latest versions of the packages?", "Ok", "Cancel");
+ if (res) {
+ foreach (var dep in missingDependencies) {
+ UnityEditor.PackageManager.Client.Add(dep.name);
+ }
+ }
+ }
+
+ // E.g. 2023.3.0b8
+ var v = Application.unityVersion.Split('.');
+ UnityEngine.Assertions.Assert.IsTrue(v.Length >= 3, "Unity version string is not in the expected format");
+ var major = int.Parse(v[0]);
+ var minor = int.Parse(v[1]);
+ // Filter out non-digits from v[2]
+ v[2] = new string(v[2].TakeWhile(char.IsDigit).ToArray());
+ var patch = int.Parse(v[2]);
+ if (major == 2022 && minor == 3 && patch < 21) {
+ Debug.LogError("This version of Unity has a bug which causes components in the A* Pathfinding Project to randomly stop working. Please update to unity 2022.3.21 or later.");
+ }
+ }
+ }
+}