Adding images to documents and journals

Journals and Documents provide a way of displaying multiple pages of text to the player. This script allows you to associate each page with a texture, and display that texture in a Graphic menu element.

To use it: JournalPageTexture.cs: using UnityEngine; using System.Collections; using AC; public class JournalPageTexture : MonoBehaviour { 	[SerializeField] private PageTexture[] pageTextures; [SerializeField] private string journalMenuName = "Journal"; [SerializeField] private string journalElementName = "PageText"; [SerializeField] private string graphicElementName = "Texture"; [SerializeField] private Texture2D emptyTexture; private void OnEnable { 		EventManager.OnMenuTurnOn += OnMenuTurnOn; EventManager.OnMenuElementShift += OnMenuElementShift; } 	private void OnDisable { 		EventManager.OnMenuTurnOn -= OnMenuTurnOn; EventManager.OnMenuElementShift -= OnMenuElementShift; } 	private void OnMenuTurnOn (Menu menu, bool isInstant) { 		if (menu.title == journalMenuName) { 			UpdatePageTexture ; } 	}  	private void OnMenuElementShift (MenuElement _element, AC_ShiftInventory shiftType) { 		if (PlayerMenus.GetMenuWithName (journalMenuName).elements.Contains (_element)) { 			UpdatePageTexture ; } 	}  	private void UpdatePageTexture { 		MenuJournal journal = PlayerMenus.GetElementWithName (journalMenuName, journalElementName) as MenuJournal; int pageIndex = journal.showPage - 1; MenuGraphic graphic = PlayerMenus.GetElementWithName (journalMenuName, graphicElementName) as MenuGraphic; if (pageIndex < journal.pages.Count) { 			int pageID = journal.pages [pageIndex].lineID; graphic.graphic.texture = GetTextureWithID (pageID); } 		else { 			graphic.graphic.texture = emptyTexture; } 		graphic.graphic.ClearCache ; } 	private Texture2D GetTextureWithID (int ID) { 		foreach (PageTexture pageTexture in pageTextures) { 			if (pageTexture.ID == ID) { 				return pageTexture.texture; } 		}  		return null; } 	[System.Serializable] private struct PageTexture { 		public int ID; public Texture2D texture; } }
 * 1) Create a new journal or document as normal using the Menu system.  The pages must have text - if you don't want to show them, they can be hidden from view.
 * 2) Create a new Graphic element in the Menu for page textures to be displayed in.
 * 3) Add the page text to the Speech Manager by clicking "Gather text".
 * 4) Add the script below (JournalPageTexture.cs) as a component in your scene.  This should be on a prefab present in all scenes (such as the Player) for it to be recognised game-wide.
 * 5) Fill in the Inspector fields, referencing the Menu and Element names involved.  Use the "Page Textures" array to define a texture for each page.  To connect a texture asset to a page, refer to that page's ID number as listed in the Speech Manager.