ImageLoadManager.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using static DownLoadXRManager;
  6. public class ImageLoadManager : MonoBehaviour
  7. {
  8. string type = "";
  9. public Texture2D texture2D;
  10. public void loadimage(string path)
  11. {
  12. type="image";
  13. if(path==""||path==null)
  14. {
  15. return;
  16. }
  17. Debug.Log("开始下载图片===》"+path);
  18. DownLoadResources dlr = new DownLoadResources();
  19. dlr.path = path;
  20. // 文件上传
  21. DownLoadXRManager.DownLoadForTexture(dlr, msg =>
  22. {
  23. Debug.Log("开始下载图片== 完成=》"+path);
  24. texture2D=msg;
  25. this.transform.GetComponent<RawImage>().texture = msg;
  26. },(f)=>{
  27. });
  28. }
  29. public Texture2D pdftex;
  30. string pdfpath;
  31. public void loadPdf(string path)
  32. {
  33. type="pdf";
  34. if(path==""||path==null)
  35. {
  36. return;
  37. }
  38. Debug.Log("开始下载Pdf===》"+path);
  39. DownLoadResources dlr = new DownLoadResources();
  40. dlr.path = path;
  41. // 文件上传
  42. DownLoadXRManager.DownLoadForFilePath(dlr, msg =>
  43. {
  44. pdfpath=msg;
  45. this.transform.GetComponent<RawImage>().texture = pdftex;
  46. // this.transform.GetComponent<RawImage>().texture = msg;
  47. },(f)=>{
  48. });
  49. }
  50. public void showBigTexture()
  51. {
  52. if(type=="image")
  53. {
  54. TianJiWindowManager.Instance.showPoTexure2D(5,texture2D);
  55. }
  56. else
  57. {
  58. TianJiWindowManager.Instance.showPoPdf(6,pdfpath);
  59. }
  60. }
  61. void OnDestroy()
  62. {
  63. // Destroy(texture2D);
  64. }
  65. }