Cleanup deprecation warnings in the plugin

This commit is contained in:
Michal Pikulski
2025-09-10 12:56:51 +02:00
parent e0af6b999d
commit 8491b74d5d
8 changed files with 9 additions and 9 deletions

View File

@@ -425,7 +425,7 @@ namespace Pathfinding {
// If gravity is used depends on a lot of things. // If gravity is used depends on a lot of things.
// For example when a non-kinematic rigidbody is used then the rigidbody will apply the gravity itself // For example when a non-kinematic rigidbody is used then the rigidbody will apply the gravity itself
// Note that the gravity can contain NaN's, which is why the comparison uses !(a==b) instead of just a!=b. // Note that the gravity can contain NaN's, which is why the comparison uses !(a==b) instead of just a!=b.
usingGravity = !(gravity == Vector3.zero) && (!updatePosition || ((rigid == null || rigid.isKinematic) && (rigid2D == null || rigid2D.isKinematic))); usingGravity = !(gravity == Vector3.zero) && (!updatePosition || ((rigid == null || rigid.isKinematic) && (rigid2D == null || rigid2D.bodyType == RigidbodyType2D.Kinematic)));
if (rigid == null && rigid2D == null && canMove) { if (rigid == null && rigid2D == null && canMove) {
Vector3 nextPosition; Vector3 nextPosition;
Quaternion nextRotation; Quaternion nextRotation;

View File

@@ -677,7 +677,7 @@ public class AstarPath : VersionedMonoBehaviour {
/// </summary> /// </summary>
public static void FindAstarPath () { public static void FindAstarPath () {
if (Application.isPlaying) return; if (Application.isPlaying) return;
if (active == null) active = GameObject.FindObjectOfType<AstarPath>(); if (active == null) active = FindFirstObjectByType<AstarPath>();
if (active != null && (active.data.graphs == null || active.data.graphs.Length == 0)) active.data.DeserializeGraphs(); if (active != null && (active.data.graphs == null || active.data.graphs.Length == 0)) active.data.DeserializeGraphs();
} }
@@ -1222,7 +1222,7 @@ public class AstarPath : VersionedMonoBehaviour {
// Very important to set this. Ensures the singleton pattern holds // Very important to set this. Ensures the singleton pattern holds
active = this; active = this;
if (FindObjectsOfType(typeof(AstarPath)).Length > 1) { if (FindObjectsByType<AstarPath>(FindObjectsSortMode.None).Length > 1) {
Debug.LogError("You should NOT have more than one AstarPath component in the scene at any time.\n" + Debug.LogError("You should NOT have more than one AstarPath component in the scene at any time.\n" +
"This can cause serious errors since the AstarPath component builds around a singleton pattern."); "This can cause serious errors since the AstarPath component builds around a singleton pattern.");
} }

View File

@@ -39,7 +39,7 @@ namespace Pathfinding {
} }
public static void FindAllModifiers () { public static void FindAllModifiers () {
var allModifiers = FindObjectsOfType(typeof(GraphModifier)) as GraphModifier[]; var allModifiers = FindObjectsByType<GraphModifier>(FindObjectsSortMode.None) as GraphModifier[];
for (int i = 0; i < allModifiers.Length; i++) { for (int i = 0; i < allModifiers.Length; i++) {
if (allModifiers[i].enabled) allModifiers[i].OnEnable(); if (allModifiers[i].enabled) allModifiers[i].OnEnable();

View File

@@ -127,7 +127,7 @@ namespace Pathfinding.Serialization {
} }
if (!string.IsNullOrEmpty(guid)) { if (!string.IsNullOrEmpty(guid)) {
UnityReferenceHelper[] helpers = UnityEngine.Object.FindObjectsOfType(typeof(UnityReferenceHelper)) as UnityReferenceHelper[]; UnityReferenceHelper[] helpers = UnityEngine.Object.FindObjectsByType<UnityReferenceHelper>(FindObjectsSortMode.None) as UnityReferenceHelper[];
for (int i = 0; i < helpers.Length; i++) { for (int i = 0; i < helpers.Length; i++) {
if (helpers[i].GetGUID() == guid) { if (helpers[i].GetGUID() == guid) {

View File

@@ -341,7 +341,7 @@ namespace Pathfinding.Serialization {
} }
#if UNITY_2020_1_OR_NEWER #if UNITY_2020_1_OR_NEWER
foreach (var helper in UnityEngine.Object.FindObjectsOfType<UnityReferenceHelper>(true)) foreach (var helper in UnityEngine.Object.FindObjectsByType<UnityReferenceHelper>(FindObjectsInactive.Include, FindObjectsSortMode.None))
#else #else
foreach (var helper in UnityEngine.Object.FindObjectsOfType<UnityReferenceHelper>()) foreach (var helper in UnityEngine.Object.FindObjectsOfType<UnityReferenceHelper>())
#endif #endif

View File

@@ -29,7 +29,7 @@ namespace Pathfinding {
cam = Camera.main; cam = Camera.main;
// Slightly inefficient way of finding all AIs, but this is just an example script, so it doesn't matter much. // Slightly inefficient way of finding all AIs, but this is just an example script, so it doesn't matter much.
// FindObjectsOfType does not support interfaces unfortunately. // FindObjectsOfType does not support interfaces unfortunately.
ais = FindObjectsOfType<MonoBehaviour>().OfType<IAstarAI>().ToArray(); ais = FindObjectsByType<MonoBehaviour>(FindObjectsSortMode.None).OfType<IAstarAI>().ToArray();
useGUILayout = false; useGUILayout = false;
} }

View File

@@ -73,7 +73,7 @@ namespace Pathfinding {
} }
public static void FindAllGraphSurfaces () { public static void FindAllGraphSurfaces () {
var srf = GameObject.FindObjectsOfType(typeof(RelevantGraphSurface)) as RelevantGraphSurface[]; var srf = GameObject.FindObjectsByType<RelevantGraphSurface>(FindObjectsSortMode.None) as RelevantGraphSurface[];
for (int i = 0; i < srf.Length; i++) { for (int i = 0; i < srf.Length; i++) {
srf[i].OnDisable(); srf[i].OnDisable();

View File

@@ -27,7 +27,7 @@ namespace Pathfinding {
} else if (gameObject.scene.name != null) { } else if (gameObject.scene.name != null) {
// Create a new GUID if there are duplicates in the scene. // Create a new GUID if there are duplicates in the scene.
// Don't do this if this is a prefab (scene.name == null) // Don't do this if this is a prefab (scene.name == null)
foreach (UnityReferenceHelper urh in FindObjectsOfType(typeof(UnityReferenceHelper)) as UnityReferenceHelper[]) { foreach (UnityReferenceHelper urh in FindObjectsByType<UnityReferenceHelper>(FindObjectsSortMode.None) as UnityReferenceHelper[]) {
if (urh != this && guid == urh.guid) { if (urh != this && guid == urh.guid) {
guid = Pathfinding.Util.Guid.NewGuid().ToString(); guid = Pathfinding.Util.Guid.NewGuid().ToString();
Debug.Log("Created new GUID - " + guid, this); Debug.Log("Created new GUID - " + guid, this);