Forum rules - please read before posting.

"Is Visible?" - Showing/Hiding Menu Elements

edited February 2018 in Technical Q&A
Hello,

What I'm trying to do;
Menu contains a collection of 'Graphic' elements, all of the graphics are on the same spot in game. My goal is to use Dialogue System (3rd party) to enable/disable the graphics as part of a visual novel type adventure. It is trivial to show/hide gameobjects which was my initial plan however images as gameobjects tend to move around depending on the resolution in use and end up encroaching on some other menus that are permanently displayed. The same method used to show/hide gameobjects can be applied to AC cutscenes so assuming it is possible to show/hide part of a menu via AC, then this should work.

So locking the images into a menu seems the best way to achieve this but I am having no luck enabling/disabling elements of a menu. If I untick 'Is Visible?' there doesn't appear to be any way to make them visible via action lists, 'Show Menu Element' didn't work for me. If I make them all visible, they unsurprisingly all just appear on top of each other. 

I considered that I could have a separate menu for each image which would allow turning on/off, but that's only feasible for a few images, having 500 menus isn't going to be fun to manage! :P

I'm using the AC UI. 

Any ideas? :)

Cheers

Edit: 
I've been attempting to store all of the show/hide menu elements for a scene within the one cutscene and then using the Dialogue System calls to the cutscene to run specific steps.
AC(ImageMenu, 2) - This would have three items within the cutscene, all independent of each other. So, 0 - show an image, 1 - hide an image, 2 - show the image I want to see. All ending with stop.

This doesn't seem to work but if I have a cutscene with just a show menu element, this works as expected. I'm not sure if this is because it isn't possible to run specific tasks within an action list, such as task 2 or task 5 and ignoring all others?

Regardless, worst case scenario now is not 500 menus, just individual cutscenes for each show and hide which becomes more manageable. 

Comments

  • edited February 2018
    Whilst I have somewhat overcome my initial problem by using cutscenes with the following setup;
    ---
    Check element is visible
    If visible, hide
    If not visible, show
    ---

    Which allows me to have a single cutscene per image for enabling/disabling - not as ideal but it only adds a small step on to my original method, so no big deal. The main issue with this now though is that the image box menu is in the centre of the screen so whenever another menu is accessed, such as the pause menu, the image menu is closed. Turning off crossfade works to an extent but the Pause menu is hidden behind the image menu in this instance and then if you click anything such as load or save (just by clicking the image, can't see the buttons), the image menu is closed again. 

    All working as intended I suppose, I'm just trying to bend AC too much I think when it comes to this image box idea but I am hoping I can figure something out. What I'm trying to do just now is save the visible menu element from the images menu into a variable, this variable would then be saved and checked when transitioning between Pause and playing the game. Currently I can't see any way to save a visible element to a variable, is this a feasible solution?

    Cheers

    Edit: Works with just having a 'clear all' action list that can be run, this just contains all of the menu elements for a given location and when transitioning between areas all elements are switched off and the transitioning to element is switched on.

    Kind of swerving away from my original query now but I'm not even sure what that was anymore...
    This all works fine for normal images however using animated gif player, a Unity asset, I can get gifs working in Unity however currently there is no way I can find to attach said gif to the AC menu window for the images, so whilst all images respect whatever resolution you are playing on as they don't bash into each other, the gifs are just game objects that encroach on menus if you play at a low resolution. 

    Is it possible to allow any type of file to be assigned to the Menu: Graphic - Texture? 
  • I admit I got a bit confused going through this because of the updates and edits, as well as the fact that this is a very visual problem at its core.  If you have some images to share that explain what's going on, that may help with understanding.

    That said, here are a few thoughts that may help:
    1. The display order of AC menus is determined by their stacking in the Menu Manager list.  The display order of Unity UI-based menus is determined by the "Sort order" of the Canvas components.  AC menus will always be shown above Unity UI menus - see the "Menus overview" chapter of the Manual.
    2. If you have many elements that you want to only show one of at a time, you can run a common ActionList that hides all of them, followed by a new ActionList that just shows the one you want
    3. When performing similar tasks many times, consider using ActionList parameters - which allow you to recycle Actions by changing their fields each time.  In this case, you could have a parameterised ActionList that allows you to show a generic element and hide all others, and choose the name of that element at the time that the ActionList is run.  For more on ActionList parameters, see the Manual as well as this tutorial.
    4. Graphic elements can be linked to Image and Raw Image UI components - anything else will need custom scripting.  That said:
    5. When a Unity UI-linked Graphic element is hidden, the linked UI GameObject will be disabled - meaning any child objects will be disabled too.  You could make the linked Image component empty (serve as a dummy) and then attach the GIF component to it as a child, so that hiding the Graphic also hides the GIF component.
    6. If you're using Unity UI and working with lots of graphics that you only want to show one of, it may be better to just have one graphic and control its appearance using Animation.  Each image it could show would be set via a separate animation, and then an animator on that GameObject would have transitions etc to play a given graphic based on an animator parameter value, and you could then control that parameter value using AC's Object: Animate Action.  If controlled through animation, it wouldn't even need linked to AC's Menu Manager as a Graphic element.
  • Hi Chris,

    I don't blame you, I'm a bit confused myself reading through my posts. 

    Thanks for taking the time to look and provide your thoughts on that though, I've actually gone with your second suggestion in that I have an action list that turns off all menus for that scene, so a location menu will have 10 images for example, each image is a different sub-location, when switching between these sub-locations they are all turned off and then the destination sub-location is turned on. This works perfectly and is simple to manage.

    The big stumbling block for me is really the gif animations. 

    I only just realised that it was possible to use Unity UI prefabs however I'm not sure if these will respect the position of the other menus in the scene. Using my artistic talent, I have created this picture;

    image

    Menu 1 & 2 are always visible

    Images Menu is the position that multiple menu's will share and this is where the images and hopefully, the GIF's will be displayed. I am just turning on/off menu's and then hiding/showing their menu elements which are all 'Graphic' types (that I want to put the GIF in) via ActionLists within CutScenes. All three menu's appear to respect each others position and adjust their size and scale according to the resolution in use, unless the player starts playing on really low resolutions, which I'm not looking to resolve. 

    When I use a GameObject however, the object won't resize accordingly and encroaches on Menu 1 and Menu 2 space with slight resolution changes. I'm currently exploring options for forcing the objects to resize with their resolution but I'll still have the same issue whereby they will resize but may still sneak into menu 1 and 2. I suppose my goal was really to have everything on screen (other than the text which is dialogue system controlled) to be controlled by the AC menu system. 

    I haven't been able to get suggestion 5 working and I think this would suffer the same issue as it won't be using the adventure creator menu type, which I think (?) is what resizes and aligns the menus together. (All set to aligned, upper left, upper center, upper right for example).

    If it isn't feasible to get them using the adventure creator menu using the graphics type that I'm using for images, it's not the end of the world thankfully. Plan B is to have gameobjects that contain the gifs and attach a script to the top level gameobject that forces resizing based on screen resolution. 

    Bit of a ramble again.. love the product btw, pretty sure I'd have blown my brains out by this point if I wasn't using AC as the initial framework!

    Cheers


  • Hi Chris,

    I've got things working reasonably well having a game object containing all gifs of a scene and attaching a script to adapt the dimensions on different screen sizes. Dialogue system is then used to show or hide the game objects.

    So unless you have an interest in getting animated gif player to work with the AC menu: graphic, don't waste any more time on my behalf :)

    Cheers
  • At this point, the "AC" drawing option for menus is really best suited to protoyping, while leaving Unity UI for "final" menus as they have much better styling and customisation options.

    All of the alignment etc options that AC menus have can all be recreated in Unity UI - but using Unity UI components instead of directly within the Menu Manager.  The "Anchor" options inside the RectTransform component can be used to set a UI object's alignment.

    As AC's own menu rendering system is based on OnGUI, it's likely that a gif option wouldn't be possible anyway - since UI systems are (and rightly should be) generally geared towards Unity UI now.
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.