1.里面有用到PDF插件,如果你沒有插件可以去下面鏈接下載:
有積分了可以直接下,沒有的可以評論聯系我,給你發
2. 這是設置對象
下面上腳本
using Paroxe.PdfRenderer; using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; using UnityEngine.UI; public class DocumentGroup : MonoBehaviour { public float m_Page = 0; string downloadFileName; //pdf 地址 public GameObject link; //plane 也可以 public RawImage rawImage; //UI 也可以 private void Update() { m_Page += Time.deltaTime; PrintLocalPDF(); } public void PrintLocalPDF() { #if UNITY_EDITOR downloadFileName = Application.dataPath + "/wcl.pdf"; print(downloadFileName); #elif UNITY_ANDROID downloadFileName = Application.persistentDataPath+"/wcl.pdf"; #endif PDFDocument pdfDocument = new PDFDocument(downloadFileName); if (pdfDocument.IsValid) { int pageCount = pdfDocument.GetPageCount(); PDFRenderer renderer = new PDFRenderer(); Texture2D tex = renderer.RenderPageToTexture(pdfDocument.GetPage((int)m_Page % pageCount), 1024, 1024); tex.filterMode = FilterMode.Bilinear; tex.anisoLevel = 8; // link.GetComponent<MeshRenderer>().material.mainTexture = tex; rawImage.texture = tex; } } }
運行就能播放了,具體擴展看自己需求