Cleanup deprecation warnings in the plugin
This commit is contained in:
@@ -425,7 +425,7 @@ namespace Pathfinding {
|
||||
// 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
|
||||
// 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) {
|
||||
Vector3 nextPosition;
|
||||
Quaternion nextRotation;
|
||||
|
||||
@@ -677,7 +677,7 @@ public class AstarPath : VersionedMonoBehaviour {
|
||||
/// </summary>
|
||||
public static void FindAstarPath () {
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -1222,7 +1222,7 @@ public class AstarPath : VersionedMonoBehaviour {
|
||||
// Very important to set this. Ensures the singleton pattern holds
|
||||
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" +
|
||||
"This can cause serious errors since the AstarPath component builds around a singleton pattern.");
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Pathfinding {
|
||||
}
|
||||
|
||||
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++) {
|
||||
if (allModifiers[i].enabled) allModifiers[i].OnEnable();
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace Pathfinding.Serialization {
|
||||
}
|
||||
|
||||
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++) {
|
||||
if (helpers[i].GetGUID() == guid) {
|
||||
|
||||
@@ -341,7 +341,7 @@ namespace Pathfinding.Serialization {
|
||||
}
|
||||
|
||||
#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
|
||||
foreach (var helper in UnityEngine.Object.FindObjectsOfType<UnityReferenceHelper>())
|
||||
#endif
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Pathfinding {
|
||||
cam = Camera.main;
|
||||
// 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.
|
||||
ais = FindObjectsOfType<MonoBehaviour>().OfType<IAstarAI>().ToArray();
|
||||
ais = FindObjectsByType<MonoBehaviour>(FindObjectsSortMode.None).OfType<IAstarAI>().ToArray();
|
||||
useGUILayout = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace Pathfinding {
|
||||
}
|
||||
|
||||
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++) {
|
||||
srf[i].OnDisable();
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Pathfinding {
|
||||
} else if (gameObject.scene.name != null) {
|
||||
// Create a new GUID if there are duplicates in the scene.
|
||||
// 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) {
|
||||
guid = Pathfinding.Util.Guid.NewGuid().ToString();
|
||||
Debug.Log("Created new GUID - " + guid, this);
|
||||
|
||||
Reference in New Issue
Block a user