PackageItem.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using UnityEngine;
  2. using FairyGUI.Utils;
  3. namespace FairyGUI
  4. {
  5. /// <summary>
  6. ///
  7. /// </summary>
  8. public class PackageItem
  9. {
  10. public UIPackage owner;
  11. public PackageItemType type;
  12. public ObjectType objectType;
  13. public string id;
  14. public string name;
  15. public int width;
  16. public int height;
  17. public string file;
  18. public bool exported;
  19. public NTexture texture;
  20. public ByteBuffer rawData;
  21. public string[] branches;
  22. public string[] highResolution;
  23. //image
  24. public Rect? scale9Grid;
  25. public bool scaleByTile;
  26. public int tileGridIndice;
  27. public PixelHitTestData pixelHitTestData;
  28. //movieclip
  29. public float interval;
  30. public float repeatDelay;
  31. public bool swing;
  32. public MovieClip.Frame[] frames;
  33. //component
  34. public bool translated;
  35. public UIObjectFactory.GComponentCreator extensionCreator;
  36. //font
  37. public BitmapFont bitmapFont;
  38. //sound
  39. public NAudioClip audioClip;
  40. //spine/dragonbones
  41. public Vector2 skeletonAnchor;
  42. public object skeletonAsset;
  43. public object Load()
  44. {
  45. return owner.GetItemAsset(this);
  46. }
  47. public PackageItem getBranch()
  48. {
  49. if (branches != null && owner._branchIndex != -1)
  50. {
  51. string itemId = branches[owner._branchIndex];
  52. if (itemId != null)
  53. return owner.GetItem(itemId);
  54. }
  55. return this;
  56. }
  57. public PackageItem getHighResolution()
  58. {
  59. if (highResolution != null && GRoot.contentScaleLevel > 0)
  60. {
  61. int i = GRoot.contentScaleLevel - 1;
  62. if (i >= highResolution.Length)
  63. i = highResolution.Length - 1;
  64. string itemId = highResolution[i];
  65. if (itemId != null)
  66. return owner.GetItem(itemId);
  67. }
  68. return this;
  69. }
  70. }
  71. }