Hi! I am looking for the simplest way (if possible) to have multiple textures within the same document. Let me explain with an example. When clicking on a hotspot, it opens an element that allows me to navigate within it by clicking on the arrows, as if it were a carousel of images on a website. I'm reading the manual, and searching the forum, but at the moment I can't find the clue. Thanks!
Example:
https://imgur.com/VqBpIQu
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
So, each "page" of the Document has a different image?
See this wiki script: https://adventure-creator.fandom.com/wiki/Adding_images_to_documents_and_journals
Hi @ChrisIceBox , thanks for the quick reply! Yes, the idea is to have one or more singles documents with multiple textures inside. So that way you can toggle between them with the next and prev arrows. About the JournalPageTexture.cs I'm certanly in a newbie state in terms of scripting and the way it works within Unity or AC. So i'm trying to learn while work in my project. But maybe you can clarify some things to me
I'm a bit confussed and lost hehe! The instructions from the Wikia are about the creation of a new menu from the menu manager? Because i can't understand the way that this will be connected to the new Document created from the Inventory Manager.
This is so far what i achived:
This is the new document (the one will show three different images inside)
https://imgur.com/sGlwOgZ
Once i clicked on to "gather text":
https://imgur.com/hBZiIBd
Your Document is defined in the Inventory Manager, but a Menu is necessary to view it. The wiki script works by updating the texture of a Graphic element based on the page you're viewing.
Where have you placed the JournalPageTexture component, and what are the details of the Menu you're using to view it?
The page text you've shared now has an ID number of 434. That means: in your Journal Page Texture component, increase the Page Textures array by 1, and give that new entry an ID of 434, and set the texture.
For a Document to have a record of what page is currently open, you need to have a Journal element in your Menu to display the page text. This can be made hidden if necessary later, but keep it open while testing so that you can be sure the document is opening/turning correctly first.
@ChrisIceBox Thanks! I am understanding how it works! Anyway I think I'm doing something wrong from the new menu. Something is missing or I am overlooking some important details from the settings.
This is the error that i get on the console when click on the ShiftRight (arrow).
NullReferenceException: Object reference not set to an instance of an object
JournalPageTexture.OnMenuElementShift (AC.MenuElement _element, AC.AC_ShiftInventory shiftType) (at Assets/JournalPageTexture.cs:79)
AC.EventManager.Call_OnMenuElementShift (AC.MenuElement _element, AC.AC_ShiftInventory shiftType) (at Assets/AdventureCreator/Scripts/Managers/EventManager.cs:754)
AC.MenuJournal.Shift (AC.AC_ShiftInventory shiftType, System.Boolean doLoop, System.Int32 amount) (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuJournal.cs:677)
AC.MenuButton.ProcessClick (AC.Menu _menu, System.Int32 _slot, AC.MouseState _mouseState) (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuButton.cs:635)
AC.PlayerMenus.CheckClick (AC.Menu _menu, AC.MenuElement _element, System.Int32 _slot, AC.MouseState _mouseState) (at Assets/AdventureCreator/Scripts/Controls/PlayerMenus.cs:2260)
AC.PlayerMenus.CheckClicks (AC.Menu menu) (at Assets/AdventureCreator/Scripts/Controls/PlayerMenus.cs:1867)
AC.PlayerMenus.CheckForInput (AC.Menu menu) (at Assets/AdventureCreator/Scripts/Controls/PlayerMenus.cs:1969)
AC.PlayerMenus.CheckForInput () (at Assets/AdventureCreator/Scripts/Controls/PlayerMenus.cs:1960)
AC.StateHandler.Update () (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:195)
This is my prefab "MultipleImages" which have the script attached onto:
https://imgur.com/c2ieL1N
The document with 3 pages:
https://imgur.com/wZnT0eM
The IDs generated after the gather from the same document with 3 pages:
https://imgur.com/AbG3jfo
The new menu with the journal element:
https://imgur.com/Na02yNe
ingame:
https://imgur.com/3sy2c2X
You need to configure the Journal Page Texture component's Inspector fields to match the details in your Menu Manager.
Your Menu's name is "MultipleImages" - set this in the Inspector's "Journal Menu Name" field, instead of "Journal".
@ChrisIceBox I renamed the new menu to "Documents" and also the same for the "journal Menu Name" field. So now the button works, but the texture did not change. Keep showing the first one.
Pic for reference: https://imgur.com/gxeHcxF
Anything in the Console?
Your menu has PageText and Journal elements in it - which one is being used to display the text? Remove the other, and the name of the remaining one to match the Journal Page Texture component's "Journal Element Name" field.
@ChrisIceBox No errors related on Console.
In Menu i removed the "Journal" element leaving only "PageText" so that it matches the "Journal Element Name". This way it continues without updating the texture change.
In "Texture" I changed the "Graphic Type" to "Normal" and it worked. But the problem is that this way when clicking for the first time the first texture does not appear visible. Only becoming visible once you click back.
Do you mean things only appear when shifting left and right, or closing and re-opening the menu altogether?
If you assign a temporary texture (e.g. "green.png") into the component's "Empty Texture" field, does that show at this time?
@ChrisIceBox
"Do you mean things only appear when shifting left and right, or closing and re-opening the menu altogether?"
Yes. It's like there is some problem loading the texture the first time the game starts. I've tried putting a texture into the component's "Empty Texture" field, but it doesn't show up either.
EDIT: Error on Console:
NullReferenceException
UnityEngine.Texture.get_width () (at :0)
AC.CursorIconBase.GetAnimatedSprite (System.Boolean isActive) (at Assets/AdventureCreator/Scripts/Menu/Menu classes/CursorIcon.cs:481)
AC.MenuGraphic.SetUIGraphic () (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuGraphic.cs:382)
AC.MenuGraphic.PreDisplay (System.Int32 _slot, System.Int32 languageNumber, System.Boolean isActive) (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuGraphic.cs:305)
AC.MenuPreview.UpdatePreviewMenu (AC.Menu menu, System.Boolean isSubtitlesPreview) (at Assets/AdventureCreator/Scripts/Menu/MenuPreview.cs:113)
AC.MenuPreview.Update () (at Assets/AdventureCreator/Scripts/Menu/MenuPreview.cs:60)
@ChrisIceBox
Do you mean things only appear when shifting left and right, or closing and re-opening the menu altogether?
Yes!
If you assign a temporary texture (e.g. "green.png") into the component's "Empty Texture" field, does that show at this time?
It's occurs the same.
Like something fail to load the first time the game start.
The error message can be ignored, but I can't tell from the screenshots alone what the issue might be.
If you can create a .unitypackage file of your Managers, document textures, UI prefab (if used) and a sample scene, PM it to me and I'll see what's going on.
@ChrisIceBox Great! I sent you a pm. Thank you!