Forum rules - please read before posting.

Unity UI prefab interaction

edited October 2020 in Technical Q&A

Hi, I'm experimenting with unity UI hoping for dynamic menu sizing and stuff. I got it running despite I suspect the UI tutorial is slightly outdated, but it's displaying undesired behavior. Let's say I have a hotspot with 2 interactions: they are shown and menu is sized appropriate:
interaction1
When the hand is selected it's orange, like expected, but when the eye is selected, the hand transforms to orange eye. I want it to just become orange in its place, and not swap with interaction image:
interaction2
How can I achieve this?

My settings:
settings

Comments

  • edited October 2020

    I suspect the UI tutorial is slightly outdated,

    Can you share a link? I'll review it.

    When the hand is selected it's orange, like expected, but when the eye is selected, the hand transforms to orange eye.

    Unless the icon listed in your Cursor Manager is animated, AC should not control the appearance of a Unity UI-based Interaction button.

    Let's see the Cursor Manager's settings for the "hand" icon, as well as its associated Button component in the UI prefab. Could it be that the Button itself is set to transition to an "eye" graphic when selected?

  • I tried to follow the Inventory UI tutorial:
    https://adventurecreator.org/tutorials/creating-inventory-bar-unity-ui
    It basically says to make your design with unity ui and make it a prefab, then link it to the adventure creator menu system via canvas and boundary. I assigned the canvas prefab. I tried to open and edit the prefab and then drag the boundary - it worked, but when I exited the prefab it lost connection. Tried to drag the prefab in scene, assign it from there - same thing. Same thing for interaction buttons. The only way it worked was to make separate prefabs for every needed element, but that isn't mentioned anywhere in the tutorial. It's entirely possible I'm doing something wrong though.

    About the interaction - none animated, cursor or button:
    interact
    interact2
    I'm just doing a separate button for every interaction, then show only needed depending on hotspot ( which itself works fine ).

  • Ok I'm stupid, I forgot to change a setting in the button component. If you could just explain what I'm doing wrong in the prefab part it would be great.

  • The issue is that Unity cannot retain a connection to sub-objects in a prefab - so when you exit prefab mode, the connection is lost.

    To get around this, AC restores this connection via Constant ID components. Once you assign a UI component into the Menu Manager, you should see a "Recorded Constant ID" field appear with a number that matches that on the newly-created ConstantID component in your prefab.

    You'll need to make sure that this component is saved as part of the prefab - so if you had the prefab in the scene and dragged the scene-instance into the Menu Manager, you'll need to apply such changes back to the original prefab.

    Once the game runs, AC will reference the various UI objects via these Constant ID numbers.

    For a video tutorial to creating a Unity UI-based menu, see here.

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.