No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NavMeshSceneConverter.cs 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #if UNITY_2022_2_OR_NEWER
  2. using System;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using Unity.AI.Navigation.Editor.Converter;
  6. using UnityEditor;
  7. namespace Unity.AI.Navigation.Updater
  8. {
  9. internal class NavMeshSceneConverter : SystemConverter
  10. {
  11. public override string name => "NavMesh Scene Converter";
  12. public override string info => "Reassigns the legacy baked NavMesh to a NavMeshSurface on a game object named 'Navigation'.\nAdds a NavMeshModifier component to each game object marked as Navigation Static.";
  13. public override Type container => typeof(BuiltInToNavMeshSurfaceConverterContainer);
  14. List<string> m_AssetsToConvert = new List<string>();
  15. public override void OnInitialize(InitializeConverterContext context, Action callback)
  16. {
  17. string[] allAssetPaths = AssetDatabase.GetAllAssetPaths();
  18. foreach (string path in allAssetPaths)
  19. {
  20. if (NavMeshUpdaterUtility.IsSceneReferencingLegacyNavMesh(path))
  21. {
  22. ConverterItemDescriptor desc = new ConverterItemDescriptor()
  23. {
  24. name = Path.GetFileNameWithoutExtension(path),
  25. info = path,
  26. warningMessage = String.Empty,
  27. helpLink = String.Empty
  28. };
  29. m_AssetsToConvert.Add(path);
  30. context.AddAssetToConvert(desc);
  31. }
  32. }
  33. callback.Invoke();
  34. }
  35. public override void OnRun(ref RunItemContext context)
  36. {
  37. bool success = NavMeshUpdaterUtility.ConvertScene(context.item.descriptor.info);
  38. context.hasConverted = success;
  39. }
  40. }
  41. }
  42. #endif