Manually Upgraded Astarpath to new API

This commit is contained in:
MarcUs7 2024-12-29 15:30:32 +01:00
parent f0f1f48619
commit ecdb3826c1
8 changed files with 15 additions and 10 deletions

View file

@ -29,7 +29,12 @@ 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();
// Changed FindObjectsOfType to FindObjectsByType
// Use the new FindObjectsByType method to find all MonoBehaviours
// Then filter them by the IAstarAI interface
ais = FindObjectsByType<MonoBehaviour>(FindObjectsSortMode.None)
.OfType<IAstarAI>()
.ToArray();
useGUILayout = false;
}