AssetInfo.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace YooAsset.Editor
  5. {
  6. [Serializable]
  7. public class AssetInfo
  8. {
  9. private string _fileExtension = null;
  10. /// <summary>
  11. /// 资源路径
  12. /// </summary>
  13. public string AssetPath;
  14. /// <summary>
  15. /// 资源GUID
  16. /// </summary>
  17. public string AssetGUID;
  18. /// <summary>
  19. /// 资源类型
  20. /// </summary>
  21. public System.Type AssetType;
  22. /// <summary>
  23. /// 文件格式
  24. /// </summary>
  25. public string FileExtension
  26. {
  27. get
  28. {
  29. if (string.IsNullOrEmpty(_fileExtension))
  30. _fileExtension = System.IO.Path.GetExtension(AssetPath);
  31. return _fileExtension;
  32. }
  33. }
  34. public AssetInfo(string assetPath)
  35. {
  36. AssetPath = assetPath;
  37. AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(AssetPath);
  38. AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(AssetPath);
  39. }
  40. /// <summary>
  41. /// 是否为着色器资源
  42. /// </summary>
  43. public bool IsShaderAsset()
  44. {
  45. if (AssetType == typeof(UnityEngine.Shader) || AssetType == typeof(UnityEngine.ShaderVariantCollection))
  46. return true;
  47. else
  48. return false;
  49. }
  50. }
  51. }