Forum rules - please read before posting.

Highlight UI Objects/Inventory Items?

Hey all. As the title implies, I'm looking for a way to highlight UI elements (such as buttons). This is what I'm trying to achieve:
First-time players will trigger a variable. In a menu (when turned on) is a variable check (same variable triggered). When it's true, I'd like for a specific button to pulse continuously (I've been able to do this with game objects).

But I'm not able to do it with UI elements or with Inventory Items. Is there a specific way to achieve this?

Am I missing something when it comes to the Inventory Item? - I've tried to select Highlight Inventory Item when interacting with that Item in the Inventory Menu but it doesn't seem to work.

Thank you. If there's any tutorial, feel free to send it my way. Thank you!

Comments

  • If your Menu relies on Unity UI, you can attach an Animator to the Button to have it rely on animation for its normal/selected etc states.

    To have it then play a custom animation, you can then rely on the Object: Animate Action as normal to trigger it.

  • My menus rely on Unity UI (Prefab) not Scene, but I'm blocked by an issue or mistake I'm making. I'll post a new thread for the issue. I can't seem to play animations in canvas/UI if they're not in the scene.

    What about Inventory Highlight? How do I get the inventory items to get highlighted in Inventory menu based on ActionLists? Do I need to add the lighlight script to a prefab of the inventory object and linke that to the object? Thank you

  • The Object: Highlight Action has the option to highlight inventory items.

  • Hi, I'm wondering if the Object: Highlight still works only on AC menus or it's possible to use it with Unity UI? I tried adding the action after picking up an item but it isn't doing anything

  • Built-in, it's AC only. However, this script on the AC wiki allows you to have an Animator parameter react to this Action:

    https://adventure-creator.fandom.com/wiki/Highlight_Items_in_UI

  • Oh, I see. I added it to my project and made an animator controller, but since the slots in the prefab are empty and the images are added in game by ac, I'm not sure how to make it work, maybe I didn't understand the instructions very well. Right now the animator is sort of working (although the pulse once doesn't really pulse, it stays there, it's not resetting back to 0), but the active / highlighted image never shows up in the inventory's slots. Here's images of the inventory manager, animator controller (which I'm unsure if I set up correctly, the instructions weren't very specific) and actionlist.

  • Ah, no - the Animator will only trigger a pre-set animation, not alter the Image dynamically based on which Item is actually involved. It's more intended for a scaling effect or somesuch.

    To have the Image component update its Sprite with the highlight texture, you can replace the OnInventoryHighlight function with one that calls SetImage instead. Something along these lines:

    private void OnInventoryHighlight(InvItem invItem, HighlightType highlightType)
    {
        var menu = KickStarter.playerMenus.GetMenuWithCanvas(canvas);
        var inventoryBox = menu.GetElementWithGameObject(gameObject) as MenuInventoryBox;
        var button = inventoryBox.GetUIButtonWithItem(invItem.id);
    
        var tex = (highlightType == HighlightType.Disable) ? invItem.tex : invItem.activeTex;
        var slotIndex = inventoryBox.GetSlotIndex(button.gameObject);
        var slot = inventoryBox.uiSlots[slotIndex];
    
        slot.SetImage(tex);
    }
    
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.