ImageLoadManager.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. texture2D=msg;
  24. this.transform.GetComponent<RawImage>().texture = msg;
  25. },(f)=>{
  26. });
  27. }
  28. public Texture2D pdftex;
  29. string pdfpath;
  30. public void loadPdf(string path)
  31. {
  32. type="pdf";
  33. if(path==""||path==null)
  34. {
  35. return;
  36. }
  37. Debug.Log("开始下载Pdf===》"+path);
  38. DownLoadResources dlr = new DownLoadResources();
  39. dlr.path = path;
  40. // 文件上传
  41. DownLoadXRManager.DownLoadForFilePath(dlr, msg =>
  42. {
  43. pdfpath=msg;
  44. this.transform.GetComponent<RawImage>().texture = pdftex;
  45. // this.transform.GetComponent<RawImage>().texture = msg;
  46. },(f)=>{
  47. });
  48. }
  49. public void showBigTexture()
  50. {
  51. if(type=="image")
  52. {
  53. TianJiWindowManager.Instance.showPoTexure2D(5,texture2D);
  54. }
  55. else
  56. {
  57. TianJiWindowManager.Instance.showPoPdf(6,pdfpath);
  58. }
  59. }
  60. void OnDestroy()
  61. {
  62. Destroy(texture2D);
  63. }
  64. }