XunJianUIItem_Texture.cs 868 B

12345678910111213141516171819202122
  1. using Blue;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class XunJianUIItem_Texture : MonoBehaviour,IController
  6. {
  7. public void GetSprite(Dictionary<int, ByteClass> byteDic, int mItemID, int Index)
  8. {
  9. //Debug.LogError($"mItemID:{mItemID}, Index:{Index}");
  10. LangChaoMinIo.Instance.getFile(this.GetService<IInspectionService>().InspectionInfo.id, mItemID.ToString(), Index, Texture2D =>
  11. {
  12. if (Texture2D != null)
  13. {
  14. byteDic.Add(Index, new ByteClass() { upload = false, bytes = Texture2D.EncodeToPNG() });
  15. Sprite sprite = Sprite.Create(Texture2D, new Rect(0, 0, Texture2D.width, Texture2D.height), Vector2.zero);
  16. sprite.name = Index.ToString();
  17. GetComponent<Image>().sprite = sprite;
  18. }
  19. });
  20. }
  21. }