Forum rules - please read before posting.

Theory on how to make a close up menu from inventory - work flow and best practices ( 2D )

Hello, I was hoping somebody would be able to offer some guidance or if there is a best practice. My current project is 2D and first-person.

When the player has an item in their inventory, I want to make it so that when the item is selected, a close-up - perhaps a new menu comes on the screen with a close-up of the image in the center, desciption beneath, and hotspot on some. With the close-up ( 'on look' at in menu ), the player can then search for hot spots and items and pull items from inside a snail shell or box by clicking on it for example. Or, for argument's sake, you use a key on a padlock to open a chest - 2 items from your inventory. If this is hard to do, it is not a deal breaker. But it would be nice in my project.

When you zoom in, I'm planning on putting a description underneath the item too. Is there a simple way of doing this in FP 2D ac game? Can it be done simply in AC? OR will I need to create a detailed and custom menu for every item in the inventory?

Thank you for your help.

Comments

  • Generally speaking, there are two main ways to approach this.

    One is to create a regular Menu, and then alter it dynamically - using the Menu: Update content Action - based on what item is being shown. A tutorial can be found here.

    However, if the close-up itself is interactive (and has different Hotspot positions for each item), then I'd recommend instead considering the second approach - which is to involve "Linked prefabs".

    Essentially, you'd create a separate Unity UI Canvas prefab for each item, assign it in the item's Linked prefab field, and then spawn it using the Inventory: Scene item Action.

    While you'd need to have a separate prefab for each item, you could make use of nested prefabs / prefab variants so that it doesn't require creating a new UI from scratch each time.

    These UI prefabs wouldn't be linked to the Menu Manager, so you'd need to handle their click behaviours manually in the Button component "On Click" events. These can be made to run ActionList assets however, by invoking their "Interact" functions.

    This is a more complex approach, but does allow for the more complex features you're looking for - that is, the ability to make changes to an item's close-up through interaction. Such changes - through help of the "Remember Scene Item" component - can be saved and restored upon closing and re-opening a close-up for a given item.

    More details can be found in the Manual's "Scene items" chapter, but this is a relatively new feature, so it'll likely take a bit of back-and-forth here to get working as you intend. My advice at this point would be to start with creating a "base" UI prefab, and then using the above Action to spawn in a variant when an item is clicked in the Inventory menu.

  • Hello Chris,

    The first method sounds the most straightforward. However, I do like the idea of some parts being interactive as intended. ( I originally built this game in Flash back day, they were interactive items on close up. ) If you have already integrated a certain degree of this functionality in AC, perhaps this would be the best method going forward.

    The second method offers what I would like, although my experience with playing with UI Canvas, and customising it in Unity is lacking. But will perhaps offer the best results. I worry with this the second method that I could quickly get in way over my head. Unless editing the UI canvas is easier to design and edit than I realise.

    Thanks,

  • I'd imagine the first method's complexity would start off simple, but increase as you add more items - while the second may start off more complex, but remain fairly constant.

    Technically, the close-up doesn't necessarily need to be a UI canvas. Particularly if your game is in 2D, you could just spawn in a prefab that "looks" like a menu but instead is just regular Hotspots and Sprites. That'd certainly make it easier to have individual aspects be interactive - and you could still start off with a "Base closeup prefab" that all others derive from through the use of Prefab Variants.

  • Hello Chris, to start, I think I will stick with the simple tut that you have attached above. Basing it around the 'NewItem' as a chassis for the items for the 'gamette' I'm putting together may be the best approach.

    Interesting what you say about using something alternative to a UI canvas, And the prefab with hot spots may do the trick on another project. A few ways of coming about it then. But for now, I am following the tutorial and not getting too carried away, at the moment...

    I've run into an issue I was hoping you would be able to help with. I have followed this tutorial twice but to no avail. I have, as far as I am aware. Filled in all the fields based on the tutorial. But when I come to running the scene. The game freezes and no NewItem menu displays. It happens when I come to pick up an item. It may be worth noting that all the other menus do work prior to trying to add the menu item.

    If it is of any consequence. These are some warnings I am getting also but not sure if they are of consequence to the problem :

    "-> AC debug logger Cannot set First Person Becuase no player game be found
    UnityEngine.Debug:Log (object,UnityEngine.Object)
    AC.ACDebug:Log (object,UnityEngine.Object) (at Assets/AdventureCreator/Scripts/Static/ACDebug.cs:20)
    AC.ActionListAutosaving:AutosaveActions () (at Assets/AdventureCreator/Scripts/ActionList/Editor/ActionListAutosaving.cs:78)

    " No Player Found
    -> AC debug logger
    UnityEngine.Debug:LogWarning (object,UnityEngine.Object)
    AC.ACDebug:LogWarning (object,UnityEngine.Object) (at Assets/AdventureCreator/Scripts/Static/ACDebug.cs:33)
    AC.PlayerSpawner/d__2:MoveNext () (at Assets/AdventureCreator/Scripts/Character/PlayerSpawner.cs:156)
    AC.SaveSystem/d__51:MoveNext () (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:747)
    UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator)
    AC.SaveSystem:InitAfterLoad (int) (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:725)

    Thanks

  • edited November 2023

    It looks like your link is broken - is it intended for screenshots of your setup following the mentioned tutorial?

    The first warning you've posted also looks like it could be two merged together - though from what I can tell, they likely aren't related to this issue.

    When you say the game freezes, is that to say the game crashes, or that it just becomes unresponsive?

    If the latter, enable the AC Status box from the bottom of the Settings Manager - this should show the status of AC, and what's causing that status, in the Game window. What does it show at the time the issue occurs, and what are the states of any ActionLists that it says are running?

  • Morning. The AC status is a great tip!

    It froze the intercations only. I might - to be honest Chris - when I return - start the tutorial 'almost' from scratch and see what happens.

    I've wrapped my head around the general gist and there is no harm in me doing it again to learn.

    For the record, when the hotspot on the item was clicked to add to the inventory. Nothing happened. Even though I had created a script.

    p.s and yes, the link was from your tut.

  • If it's freezing due to an ActionList running indefinitely, you can click its name in the AC Status box to bring up the live ActionList editor window for it. The currently-running Action will be highlighted, which should offer the next clue.

  • Hello Chris, result! I managed to get the new item window to work by following the tutorial again. Thank you for the pointers.

    When the item is interacted with, it brings up a window. Now, I just need to tie this in somehow when the item in the menu is 'examined'. Any suggestions or tips? As above I guess. I won't bother with hotspots for now.

  • edited November 2023

    Nice, glad to hear things are getting there.

    I'll need a bit more detail, though. Is this a case of right-clicking the item within the new window?

    If you can share screenshots that show an example, it'll help clarify the situation.

  • I assigned it through the logic. When the player 'adds inventory item' the window, with the title, graphic and close button appears in the fore. It works!

    Mostly... which brings me to a sub-question of this... pointer / tip.

    When an item is added, and the 'new item' window is fired, one of my graphics is too large for the window and pushes the Title and close screen button out of view from the camera and screen. Is there a way - with percentages - to shrink the size of the graphic in the AC UI? Or will I have to into Photoshop and knock 30% of the size of the graphic and re-import it? I would prefer to constrain it in Unity to save time. And I would prefer to not use absolute pixels. I'm open to approaches though.

  • If the Size field is set to Manual, it should stay fixed. Though, the best approach would be to use Unity UI - as this does away with AC-set size properties, and relies entirely on easily-configurable Unity UI components.

    A tutorial on converting AC menus to Unity UI can be found here.

  • Hello Chris, if I go down the Unity UI road, from memory will this impact how all UI is handled in AC or just that component? Eg - the new item window. If it is a rabbit hole that breaks what I have made I will try to avoid it. thank you for the heads up by the way! And a Merry Christmas to AC.

  • I'd recommend being consistent with your Menu "Source" values, but strictly-speaking it is a per-Menu option, and the settings of one Menu won't affect another.

    The main thing to be mindful of is that AC menus will always be rendered atop Unity UI ones.

    Was your Size field set to Manual? If not, try it - it may not be necessary to switch.

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.