Forum rules - please read before posting.

Custom Unity UI and Adventure Creator Inventory

Hello,

I was wondering if anyone could help shed some light on issues I’m having creating my custom inventory. Basically I have designed an inventory system I am very happy with using AC exclusively and the game preview version looks great but when I run my actual build I just can’t get it to scale exactly as I would like. After fiddling around with the settings I can get some parts to look OK but something is always a little off.

After doing some research I thought that perhaps recreating it using the Unity UI would be a better fit to ensure it looks consistent across all resolutions using the canvas scaler. I followed the recommended ‘Creating an Inventory Bar in Unity UI’ tutorial (and watched some other videos on the topic) and visually it does scale much better now. However, I am now struggling to get it to function the way my original interface did. Apologies if some of this is very obvious but I’m just starting out with this and trying to learn how Unity UI and AC work together.

I will link a video (hopefully) to both versions with timestamps to help demonstrate what I want and my issues.

https://imgur.com/a/LRlUxNj

Problems -

  1. When opening the inventory (via clicking a satchel icon) how can I make it fade in and pan up from the bottom of the screen like before? I used Canvas Group Fade but would also like it to pan up too. Do I have to do a custom ‘Transition Type Animation’ for that instead? (AC 0:19) (Unity 0:26)

  2. When I click an arrow button or inventory slot during gameplay it loses it’s highlight effect and it won’t return until another button is pressed, as it’s a button I assume it is switching off when clicked. The highlight was made using the sprite swap option in the InventoryBar prefab. I would like the highlight to remain whenever the object is moved over, while clicking it (repeatedly if need be) and still available again without having to click something else first to reactivate it as with my AC version. I tried using a pressed sprite too but it's not quite the constant highlight I was looking for as it makes the highlight toggle on and off between clicks and adding a selected sprite doesn't allow for it to switch off automatically when the cursor leaves it. Should I be going about this in a different way and not using a simple sprite swap? (AC 0:15 repeatedly clicking and highlight remains) (Unity 0:20 one click and the highlight is off)

  3. When an item is added to an inventory slot (via the AC inventory system linked to the Unity UI) the inventory slot source image vanishes leaving just the item there with no background anymore. One is being swapped for the other instead of co-existing. In the AC version the item automatically appeared on top of the assigned background texture and didn’t replace it. I’m not sure how to recreate this in Unity UI. (AC - can be seen throughout, file icon displayed correctly in slot) (Unity - can be seen throughout, file icon has replaced the slot background)

  4. When an item is stored in an inventory slot (as mention in No.3 the slot background image vanishes) moving over it swaps the Item image out for the slot highlight image. So instead of highlighting the slot around the item it replaces the item completely. I simply want the slot background to remain, the item to be displayed inside it and the outer edge to highlight when moved over. (AC 0:13) (Unity 0:14)

  5. In my AC version I had it setup to display empty inventory slots but only the ones containing something would highlight when moved over. They either all highlight in the Unity UI or I have to have the empty ones turned of which I don’t want. Any advice on fixing this to mimic the AC version? I might just be missing a simple option somewhere. (AC 0:13) (Unity 0:06)

Any help with any of this would be greatly appreciated. I did try to solve these issues myself but it’s tricky finding the exact solutions to my specific problems when I'm not familiar with the ins and out of things yet.

Thank you,

Sian

Comments

  • Welcome to the community, @Sian.

    After doing some research I thought that perhaps recreating it using the Unity UI would be a better fit to ensure it looks consistent across all resolutions using the canvas scaler.

    Indeed - Unity UI is much more flexible in terms of the design options it offers, as well as handling scaling better on various resolutions. While the AC menu system is good for rapid prototyping and simple interfaces, I'd recommend generally swiching to Unity UI anyway for final polish.

    1. The "Canvas Group Fade" option is more of a convenience tool than anything, since fading is the most common animation style. For anything else, yes - you'll have to rely on a Custom Animation transition. This involves attaching an Animator to your root Canvas and supplying it with animations named "On", "Off", "OnInstant" and "OffInstant". These will be triggered automatically when the Menu is turned on and off. For an example, see the "AnimatedMenu_Example" Animator in /Assets/AdventureCreator/UI, as well as the Manual's "Unity UI menus" chapter.

    2. What Image component are you controlling with the sprite swap transition? The one used to display the actual inventory item? Generally, that should be left alone - since AC will set the "normal" sprite to a specific item, causing the item to disappear when set to a generic highlight sprite. Something you could look into instead would be to have a separate Image child component, and use this for the highlighting effect. By setting the Transition instead to Animation, you could then have it animated to show the highlighted sprite when highlighted, and hidden otherwise. As for behaviour when clicking, however, that may be more of a Unity UI issue. I'd recommend testing with a separate, AC-unlinked, UI canvas to see how Unity UI behaves by itself.

    3. I'm not sure at what point in each video I should be looking at here, but this may be similar to 2) in that the background and item images should be kept separate. I'm not clear on how you've set up your UI Hierarchy beyond the tutorial, but I'd suggest having your background graphics be in a separate GameObject alongside your Buttons - not children of them.

    4. This seems to be a continuation of 3. One alternative to consider, though, is that you can incorporate the background / highlighting effects into the inventory item's "Main graphic" and "Active graphic" texture fields in the Inventory Manager (i.e. the item sprite shows both the item and the background in one image). You can assign a separate, background-less image to the item's "Cursor (optional)" texture for when the item is selected. Just be sure to check Show Active FX when Cursor hovers over Item in Menu? in the Settings Manager to have the active graphic act like a highlight.

    5. If you incorporate the highlighting into the item as in 4., then that should cause this to work here as well. Otherwise, try setting the InventoryBox element's When slot is empty field to Disable Object.

  • Hi Chris,

    Thank you so much for taking the time to reply so thoroughly. Your advice was extremely helpful and got me back on track. Turning on Show Active FX was a huge help!

    In case anyone has similar issues with their inventory slots swapping graphics incorrectly and problems highlighting slots, as Chris suggested there are a few fixes. I went with the method of incorporating the slot background and highlight effect directly into the inventory items main and active graphics. Then I turned on the Show Active FX when cursor hovers over item in Menu (AC Game Editor: Settings Tab). This helped me achieve the look I was after tinkering with a few other minor settings like the slot empty setting for example.

    I still have to try animating the inventory bar to pan up and fade in but I will use the “AnimatedMenu_Example” and manual as suggested as my starting point. As for the arrow buttons I haven't tackled that quite yet but I'm relieved the slots are working as expected now as that was the biggest issue.

    Thanks again for your quick support Chris.

    Sian

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.
Do NOT follow this link or you will be banned from the site!