Forum rules - please read before posting.

Adding Journal Page with textures in run time

edited May 2019 in Technical Q&A

I have seen a thread about diary system with textures.
https://adventurecreator.org/forum/discussion/8058/creating-a-diary-system-like-the-ones-in-uncharted-nitw
I have read the content but found that the link from "pasteall.org" can't be accessed any more.
I would like to add Journal page with textures in run time but can't find a way.
Is there any way I can access the links.
Thanks.

Comments

  • Welcome to the community, @o3428320d.

    Yes, it seems pasteall is having some problems right now.

    I believe this was the script in question:

    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;
    
        }
    
    }
    
  • Chris, thanks for your feedback.
    I am using the script, the script helps put different textures according to the journal pages before the game. It is good.
    However, when I add actionlist to add jounal page, there is only field to input text but no texture. Is there any way I can add journal page with texture when the game run.
    Thanks a lot.

  • Gather your scene's text via the Speech Manager, which will also give the added pages their own ID values. You can still reference these IDs in the script's Inspector, even if they're not yet added to the journal itself.

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.