using System.Collections.Generic; using UnityEngine; namespace PDFViewer.Scripts { public class PDFDisplay : MonoBehaviour { public int currentPageIndex = 0; [SerializeField] ConvertedPDF convertedPDFAsset = default; public KeyCode next; public KeyCode previous; List pages; string pdfPath; void Start() { if (convertedPDFAsset == null) Debug.LogError("Null PDF File", this); pages = convertedPDFAsset.Pages; if(pages.Count == 0) { Debug.LogError("No Pages specified"); return; } SetToPage(currentPageIndex); } void SetToPage(int pageIndex) { gameObject.GetComponent().material.mainTexture = pages[pageIndex]; } // Update is called once per frame void Update() { if (Input.GetKeyDown(next) && currentPageIndex < pages.Count) { GoToNextPage(); } else if (Input.GetKeyDown(previous) && currentPageIndex > 0) { GoToPreviousPage(); } } void GoToPreviousPage() { currentPageIndex--; SetToPage(currentPageIndex); } void GoToNextPage() { currentPageIndex++; SetToPage(currentPageIndex); } } }