PdfManager.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using Paroxe.PdfRenderer;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. using static LangChaoRommMinIo;
  7. public class PdfManager : BaseFilePrefabItem
  8. {
  9. private PDFViewer pdfview;
  10. public override void Init(FileConfig fileConfig)
  11. {
  12. base.Init(fileConfig);
  13. if (!string.IsNullOrEmpty(fileConfig.Url))
  14. {
  15. string url = fileConfig.Url;
  16. if (!fileConfig.Url.Contains("http"))
  17. {
  18. url = "https://" + fileConfig.Url;
  19. }
  20. LangChaoRommMinIo.Instance.getFile(MQTTManager.Instance.roomId, fileConfig.Bucket, fileConfig.ObjectName, (RoomFileData rfd) => {
  21. Debug.Log("rfd==>" + rfd.url);
  22. Debug.Log("rfd==>" + rfd.bytes.Length);
  23. string url = rfd.url;
  24. showPDF(url);
  25. });
  26. }
  27. }
  28. public void showPDF(string url)
  29. {
  30. //this.transform.localPosition = new Vector3(0,0,0.69f);
  31. pdfview = this.GetComponent<PDFViewer>();
  32. pdfview.FileURL = url;
  33. pdfview.LoadDocument();
  34. }
  35. public override void OnScaleStopped()
  36. {
  37. if (transform.localScale.x < 0.0001f)
  38. {
  39. transform.localScale = new Vector3(0.0001f, 0.0001f, 0.0001f);
  40. }
  41. }
  42. }