123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using Paroxe.PdfRenderer;
- using UnityEngine;
- using UnityEngine.UI;
- public class PopWindowManager : MonoBehaviour
- {
- public PDFViewer pDFViewer;
- public static Texture texture;
- public RawImage image;
- public static string info;
- public static string pdfpath;
- public Text fivetext;
- public static PopWindowManager Instance;
- void Awake()
- {
- Instance=this;
- }
- public List<GameObject> golist;
- public static int indexwd;
- public Action<int> callback;
- public void OnEnable()
- {
- image.texture = texture;
- if(pdfpath!=""&&pdfpath!=null)
- {
- pDFViewer.FilePath=pdfpath;
- }
- fivetext.text = info;
- for (int i=0;i<golist.Count;i++)
- {
- golist[i].SetActive(false);
- }
- golist[indexwd].SetActive(true);
- StartCoroutine(readpdf());
- SetImageFullScreen();
- }
- IEnumerator readpdf()
- {
- yield return new WaitForSeconds(1f);
- Debug.Log("pdfpath===>"+pdfpath);
- if(pdfpath!=""&&pdfpath!=null)
- {
- Screen.autorotateToLandscapeLeft = true;
- Screen.autorotateToLandscapeRight = true;
- Screen.autorotateToPortrait = true;
- Screen.autorotateToPortraitUpsideDown = true;
- pDFViewer.LoadDocumentFromFile(pdfpath);
- pdfpath="";
- }
- }
- void SetImageFullScreen()
- {
- if(image.texture==null)
- {
- return;
- }
-
- float screenAspect = (float)Screen.width / Screen.height;
- float imageAspect = (float)image.texture.width / image.texture.height;
-
-
- if (screenAspect > imageAspect)
- {
-
- image.rectTransform.sizeDelta = new Vector2(
- Screen.height * imageAspect,
- Screen.height
- );
- }
- else
- {
-
- image.rectTransform.sizeDelta = new Vector2(
- Screen.width,
- Screen.width / imageAspect
- );
- }
-
-
- image.rectTransform.anchoredPosition = Vector2.zero;
- }
- }
|