暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.IO;
  3. using UnityEditor;
  4. using Codice.Client.BaseCommands;
  5. namespace Unity.PlasticSCM.Editor.AssetUtils
  6. {
  7. internal static class LoadAsset
  8. {
  9. internal static UnityEngine.Object FromChangeInfo(ChangeInfo changeInfo)
  10. {
  11. string changeFullPath = changeInfo.GetFullPath();
  12. if (MetaPath.IsMetaPath(changeFullPath))
  13. changeFullPath = MetaPath.GetPathFromMetaPath(changeFullPath);
  14. return FromFullPath(changeFullPath);
  15. }
  16. static UnityEngine.Object FromFullPath(string fullPath)
  17. {
  18. if (!IsPathUnderProject(fullPath))
  19. return null;
  20. return AssetDatabase.LoadMainAssetAtPath(
  21. AssetsPath.GetRelativePath(fullPath));
  22. }
  23. static bool IsPathUnderProject(string path)
  24. {
  25. if (string.IsNullOrEmpty(path))
  26. return false;
  27. var fullPath = Path.GetFullPath(path).Replace('\\', '/');
  28. return fullPath.StartsWith(
  29. mProjectRelativePath,
  30. StringComparison.OrdinalIgnoreCase);
  31. }
  32. static string mProjectRelativePath =
  33. Directory.GetCurrentDirectory().Replace('\\', '/') + '/';
  34. }
  35. }