summaryrefslogtreecommitdiff
path: root/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Drawing/PackageTools/Editor/DependencyCheck.cs
blob: f070eb15867e5c1e499d054164dffc849fc33ba7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// 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;

namespace Pathfinding.Drawing.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.2.1-preview",
				},
#endif
#if !MODULE_MATHEMATICS
				new Dependency {
					name = "com.unity.mathematics",
					version = "1.1.0",
				},
#endif
#if !MODULE_COLLECTIONS
				new Dependency {
					name = "com.unity.collections",
					version = "0.4.0-preview",
				},
#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 ALINE 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);
					}
				}
			}
		}
	}
}