SourceAsset.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //------------------------------------------------------------
  2. // Game Framework
  3. // Copyright © 2013-2021 loyalsoft. All rights reserved.
  4. // Homepage: http://www.game7000.com/
  5. // Feedback: http://www.game7000.com/
  6. //------------------------------------------------------------
  7. using GameFramework;
  8. using UnityEditor;
  9. using UnityEngine;
  10. namespace UnityGameFramework.Editor.ResourceTools
  11. {
  12. public sealed class SourceAsset
  13. {
  14. private Texture m_CachedIcon;
  15. public SourceAsset(string guid, string path, string name, SourceFolder folder)
  16. {
  17. if (folder == null)
  18. {
  19. throw new GameFrameworkException("Source asset folder is invalid.");
  20. }
  21. Guid = guid;
  22. Path = path;
  23. Name = name;
  24. Folder = folder;
  25. m_CachedIcon = null;
  26. }
  27. public string Guid
  28. {
  29. get;
  30. private set;
  31. }
  32. public string Path
  33. {
  34. get;
  35. private set;
  36. }
  37. public string Name
  38. {
  39. get;
  40. private set;
  41. }
  42. public SourceFolder Folder
  43. {
  44. get;
  45. private set;
  46. }
  47. public string FromRootPath
  48. {
  49. get
  50. {
  51. return Folder.Folder == null ? Name : Utility.Text.Format("{0}/{1}", Folder.FromRootPath, Name);
  52. }
  53. }
  54. public int Depth
  55. {
  56. get
  57. {
  58. return Folder != null ? Folder.Depth + 1 : 0;
  59. }
  60. }
  61. public Texture Icon
  62. {
  63. get
  64. {
  65. if (m_CachedIcon == null)
  66. {
  67. m_CachedIcon = AssetDatabase.GetCachedIcon(Path);
  68. }
  69. return m_CachedIcon;
  70. }
  71. }
  72. }
  73. }