TemplateImage.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using System.IO;
  6. public class TemplateImage : BaseTemPlate
  7. {
  8. private Image m_Image;
  9. public Image M_Image
  10. {
  11. get
  12. {
  13. if(m_Image ==null)
  14. {
  15. m_Image = CacheTransform.Find("Canvas/Image").GetComponent<Image>();
  16. }
  17. return m_Image;
  18. }
  19. set
  20. {
  21. }
  22. }
  23. protected override void OnEnable()
  24. {
  25. base.OnEnable();
  26. if (GameManager.Instance.IsRuning && m_Image.sprite == null && Data != null)
  27. {
  28. DownloadManager.Instance.GetImage(Data, m_Image);
  29. }
  30. }
  31. protected override void OnAwake()
  32. {
  33. base.OnAwake();
  34. m_Image = CacheTransform.Find("Canvas/Image").GetComponent<Image>();
  35. HideCollider();
  36. }
  37. public override void SetData(MaterialObjValue value, int updateTime)
  38. {
  39. base.SetData(value, updateTime);
  40. if (!GameManager.Instance.IsRuning)
  41. {
  42. //DownloadManager.Instance.AddDownloadData(Data);
  43. }
  44. else
  45. {
  46. DownloadManager.Instance.GetImage(Data, m_Image);
  47. }
  48. }
  49. public void SetLocaImageData(MaterialObjValue value)
  50. {
  51. m_Image.sprite = ResMgr.Instance.Load<Sprite>(value.DownloadPath);
  52. }
  53. public override void HideCollider()
  54. {
  55. base.HideCollider();
  56. }
  57. }