Forum rules - please read before posting.

Document Menu Question

Hi Chris!
I got a question regarding Documents menu. Is it possible to scroll not only text by ShiftLeft and ShiftRight, but also a texture (i.e. "flip pages")? If not, do you plan to add such feature in the future?
Thank you!
With best regards , Dennis.
«1

Comments

  • Welcome to the community, @disya75.

    Can you share some illustrations to explain how you mean?  I'm not totally sure on what it is you're asking.

    A Document can be assigned a "global" texture, but you can't assign a texture to each individual page.  You could likely allow for this through custom scripting, however, using custom events.
  • edited September 2018
    Hi Chris!
    _... but you can't assign a texture to each individual page

    Yeah , that`s I mean... I`m not a programmer and no savvy how to do  this through custom script... Can you help?
    Something like this:

    https://i.imgur.com/7iiWTLV.png



  • That might show how the Editor might look, but not the end result.

    Custom scripting wouldn't involving making changes to the editor, but adding scripts to your scene to make additions at runtime.

    What I'm asking to see is what you actually want to be able to do in-game.  A screenshot of what kind of document you want to have.  For example, where would such a "page" texture be displayed?
  • Hello Chris!
     I should like this:

    https://imgur.com/a/QzgKSEU

    For instance, photo album with short notes about each photo. Or dossiers of the actors, with short description of each, and also a photo
  • edited September 2018
    Thank you, that's better.

    How many such documents are you looking to have in your game?

    I shall have a think about the best way to achieve that - I'll post here when I have something.
  • Thank you for your responsiveness!
    I think I will need 5 or 6 of such documents:
    Photoalbum , Characters , Equip , Weapons , Items... may be something else.
    Thank you very much for your help!
  • Try this:

    Paste it in a C# script named DocumentPageTextures, and attach it to a new GameObject in your scene.  Fill in the Inspector fields (Document ID, which is to the left of a Document's name in the Inventory Manager; and the textures as an array).

    It works by changing your Menu at runtime, so you'll need to select the original Document menu in your Menu Manager, select the Texture element, and set its Graphic type to Normal.  It accesses the Menu and elements by name, so you'll need to make sure the names match up with the script if you've changed them.

    It's one instance of the script per Document, so you'll need to add a new component to the same GameObject per script - each with a different Document ID.  Once it's working in one scene, you can have it work for all by making the new GameObject a prefab, and placing it in each scene.
  • Wow! Everything works great!
    You are the best developer!
    Thank you very much!!!

  • Hi @ChrisIceBox and @disya75
    I'm trying to create a journal with textures as you've discussed above as well. Through following this post and other ones, I've been able to create a functional journal with double pages, buttons etc.

    I've followed the steps detailed here but the textures don't seem to show up, I don't know why. I've kept the name of the menus the same as that in the script as well. 

    Any idea what I'm missing?

    Here's some images of the editor.
    Thanks!






    image



  • Be sure to check the Console window for errors that point you to the source of the issue.

    1) The script reads the current "page number" from the Journal element named "PageText".  I'm guessing that your own Menu has this named "Journal" - you can either rename the element, or amend the script.

    2) The Document ID in the component must match up with the ID in the Inventory Manager.  That's the number of the left of the document's name - in the screenshot you've shown, that's "1", not "0".
  • edited September 2018
    Ah the issue was a stray EventSystem object in the project. Removed it and it works.

    But the issue now is that the textures don't seem to change with the pages. It stays stuck on the first image even when changing the pages. I created a single page journal instead of a double one but the problem remains.

    I think there'll be problems making it work for a double page system but I'll try and make it work for a single system first.

    Here's links to images showing no change in texture after flipping pages, and inspector properties:

    https://imgur.com/Zkvs7yW
    https://imgur.com/cXOEdff

    Edit: And another question - is it possible to add more pages during runtime like it is for the Journals? Something like Menu>Change state>Add Journal Page.

    I intend to keep updating the diary/ document as the player discovers stuff. Kind of like where they receive a "entry added" notification which they can read by opening the diary/ document.

    A completely new document can be added but I'm not sure whether I should use a separate document for each new page.
  • Indeed - for a two-page system, the script would need to be adapted to affect two MenuGraphic elements.  It can be done, but I'd recommend getting it working for just one first, as you are now.

    Is the one image that is showing being set by the script, or is that part of the UI prefab?

    Did you amend the "Document ID" Inspector field?

    I suspect that this is because you're using Unity UI - you can test this by temporarily switching your Menu's Source back to Adventure Creator.

    If so, while it's likely better to just disconnect the Image component from the Menu Manager and just manipulate it directly, you should be able to refresh the Graphic element by calling:

    PlayerMenus.GetMenuWithName ("Document").ResetVisibleElements ();

    After updating the page texture (line 53 in the script).
  • edited October 2018
    The image is being run by the script. The UI prefab just has a blank image (sprite -none) to denote the area for the texture, and has been assigned to the graphic element in the menu (not sure if this is a necessary step)

    The ID field is correct now.

    Switching to AC menu did make the textures switch correctly.

    "while it's likely better to just disconnect the Image component from the Menu Manager and just manipulate it directly" - how can the image be manipulated directly? Removing the Image component made the texture disappear altogether.

    With the image component intact, I updated the script by adding the suggested code below line 53 and saved, but it made no difference.

    The code should look like this?


                MenuGraphic graphic = PlayerMenus.GetElementWithName("Document", "Texture") as MenuGraphic;
                graphic.graphic.texture = pageTextures[pageIndex];

                PlayerMenus.GetMenuWithName("Document").ResetVisibleElements();
            }
        }

    }


  • I wasn't saying remove the Image component from the Canvas prefab - but to disconnect it from the Menu Manager (so that AC has no control over it) so that you can manipulate the Image component through script.

    Replace the ResetVisibleElements line with:

    graphic.graphic.ClearCache ();
  • edited October 2018
    Cool, that worked! I have more questions about this journal (double page version, ability to add pages through action lists) that I'll get to in a bit - shall I continue on this thread or do you recommend creating a new topic? Thanks as always! :) 
  • No problem - a new thread'd be best, thanks.
  • No problem - a new thread'd be best, thanks.
  • Hi Chris, I would be interested in the code that you pasted above:

    http://pasteall.org/1221068/csharp

    But I don't think it's available anymore. Is there any chance that you could repost it?

    Thanks!

  • I'm afraid it's been lost, though perhaps @armaan or @disya75 still have a copy.

  • Thanks Chris, let's see if they have still have a copy.

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.