ATSdkUtil.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Runtime.InteropServices;
  7. using System.Text;
  8. using UnityEngine;
  9. // #if UNITY_EDITOR //是Unity编辑器才引入
  10. using UnityEditor;
  11. // #endif
  12. public class ATSdkUtil
  13. {
  14. // #if UNITY_EDITOR
  15. /// <summary>
  16. /// Gets the path of the asset in the project for a given Anythink plugin export path.
  17. /// </summary>
  18. /// <param name="exportPath">The actual exported path of the asset.</param>
  19. /// <returns>The exported path of the MAX plugin asset or the default export path if the asset is not found.</returns>
  20. public static string GetAssetPathForExportPath(string exportPath)
  21. {
  22. var defaultPath = Path.Combine("Assets", exportPath);
  23. var assetLabelToFind = "l:al_max_export_path-" + exportPath.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
  24. var assetGuids = AssetDatabase.FindAssets(assetLabelToFind);
  25. return assetGuids.Length < 1 ? defaultPath : AssetDatabase.GUIDToAssetPath(assetGuids[0]);
  26. }
  27. public static bool Exists(string filePath)
  28. {
  29. return Directory.Exists(filePath) || File.Exists(filePath);
  30. }
  31. // #endif
  32. }