Forum rules - please read before posting.

Document Menu Question

2»

Comments

  • edited August 2019

    Hi @NoMoonGames ! I'll take a look now and get back to you :)

    Edit:

    This should be it. Pasting it here for future reference!

    using UnityEngine;
    using System.Collections;
    using AC;
    
    public class DocumentPageTextures : MonoBehaviour
    {
    
        public int documentID;
        public Texture2D[] pageTextures;
    
    
        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 == "Document")
            {
                UpdatePageTexture();
            }
        }
    
    
        private void OnMenuElementShift(MenuElement _element, AC_ShiftInventory shiftType)
        {
            if (PlayerMenus.GetMenuWithName("Document").elements.Contains(_element))
            {
                UpdatePageTexture();
            }
        }
    
    
        private void UpdatePageTexture()
        {
            if (KickStarter.runtimeDocuments.ActiveDocument != null &&
                    KickStarter.runtimeDocuments.ActiveDocument.ID == documentID)
            {
                MenuJournal journal = PlayerMenus.GetElementWithName("Document", "Journal") as MenuJournal;
                int pageIndex = journal.showPage - 1;
    
                MenuGraphic graphic = PlayerMenus.GetElementWithName("Document", "Texture") as MenuGraphic;
                graphic.graphic.texture = pageTextures[pageIndex];
    
                graphic.graphic.ClearCache();
            }
        }
    
    }
    
  • that's great, many thanks! :smile:

  • You're welcome :smile:

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.
Do NOT follow this link or you will be banned from the site!