Asset.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 System;
  8. using UnityEditor;
  9. namespace UnityGameFramework.Editor.ResourceTools
  10. {
  11. /// <summary>
  12. /// 资源。
  13. /// </summary>
  14. public sealed class Asset : IComparable<Asset>
  15. {
  16. private Asset(string guid, Resource resource)
  17. {
  18. Guid = guid;
  19. Resource = resource;
  20. }
  21. public string Guid
  22. {
  23. get;
  24. private set;
  25. }
  26. public string Name
  27. {
  28. get
  29. {
  30. return AssetDatabase.GUIDToAssetPath(Guid);
  31. }
  32. }
  33. public Resource Resource
  34. {
  35. get;
  36. set;
  37. }
  38. public int CompareTo(Asset asset)
  39. {
  40. return string.Compare(Guid, asset.Guid, StringComparison.Ordinal);
  41. }
  42. public static Asset Create(string guid)
  43. {
  44. return new Asset(guid, null);
  45. }
  46. public static Asset Create(string guid, Resource resource)
  47. {
  48. return new Asset(guid, resource);
  49. }
  50. }
  51. }