summaryrefslogtreecommitdiff
path: root/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/ExampleScenes/ExampleScripts/MinimumUnityVersionWarning.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/ExampleScenes/ExampleScripts/MinimumUnityVersionWarning.cs
parent3ba4020b69e5971bb0df7ee08b31d10ea4d01937 (diff)
+ astar project
Diffstat (limited to 'Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/ExampleScenes/ExampleScripts/MinimumUnityVersionWarning.cs')
-rw-r--r--Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/ExampleScenes/ExampleScripts/MinimumUnityVersionWarning.cs59
1 files changed, 59 insertions, 0 deletions
diff --git a/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/ExampleScenes/ExampleScripts/MinimumUnityVersionWarning.cs b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/ExampleScenes/ExampleScripts/MinimumUnityVersionWarning.cs
new file mode 100644
index 0000000..966d301
--- /dev/null
+++ b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/ExampleScenes/ExampleScripts/MinimumUnityVersionWarning.cs
@@ -0,0 +1,59 @@
+#pragma warning disable IDE0051
+
+using System.Collections;
+using UnityEngine;
+using Pathfinding.Util;
+
+namespace Pathfinding.Examples {
+ [ExecuteInEditMode]
+ [HelpURL("https://arongranberg.com/astar/documentation/stable/minimumunityversionwarning.html")]
+ public class MinimumUnityVersionWarning : MonoBehaviour {
+#if !MODULE_ENTITIES || !UNITY_2022_2_OR_NEWER
+ bool requiresUnity2022_2;
+ bool requiresEntities;
+
+
+ void Awake () {
+ requiresEntities = UnityCompatibility.FindAnyObjectByType<Pathfinding.FollowerEntity>() != null || UnityCompatibility.FindAnyObjectByType<Pathfinding.Examples.LightweightRVO>() != null;
+ // Box colliders from scenes created in Unity 2022+ are not compatible with older versions of Unity. They will end with the wrong size.
+ // The minimum version of the entitites package also requires Unity 2022
+ requiresUnity2022_2 = UnityCompatibility.FindAnyObjectByType<BoxCollider>() != null || requiresEntities;
+ }
+
+ IEnumerator Start () {
+ // Catch dynamically spawned prefabs
+ yield return null;
+ Awake();
+ }
+#endif
+
+ void OnGUI () {
+#if !UNITY_2022_2_OR_NEWER
+ if (requiresUnity2022_2) {
+ var rect = new Rect(Screen.width/2 - 325, Screen.height/2 - 30, 650, 60);
+ GUILayout.BeginArea(rect, "", "box");
+ GUILayout.Label("<b>Unity version too low</b>\nThis example scene can unfortunately not be played in your version of Unity, due to compatibility issues.\nYou must upgrade to Unity 2022.2 or later.");
+ GUILayout.EndArea();
+ return;
+ }
+#endif
+
+#if !MODULE_ENTITIES
+ if (requiresEntities) {
+ var rect = new Rect(Screen.width/2 - 325, Screen.height/2 - 30, 650, 80);
+ GUILayout.BeginArea(rect, "", "box");
+#if UNITY_EDITOR
+ GUILayout.Label("<b>Just one more step</b>\nThis example scene requires version 1.0 or higher of the <b>Entities</b> package to be installed.");
+ if (GUILayout.Button("Install")) {
+ UnityEditor.PackageManager.Client.Add("com.unity.entities");
+ }
+#else
+ GUILayout.Label("<b>Just one more step</b>\nThis example scene requires version 1.0 or higher of the <b>Entities</b> package to be installed\nYou can install it from the Unity Package Manager");
+#endif
+ GUILayout.EndArea();
+ return;
+ }
+#endif
+ }
+ }
+}