Forum rules - please read before posting.

How to offset inventory curser text

I have a glass shard as the cursor in my game, where I've offset the sprite so the interaction point is in the top left corner of the sprite, just like a regular arrow mouse curser. That all works nicely with the text displaying above.
Now I've made it so the cursor also change into the inventory items, but here the sprite is on top of the text. It seems like the interaction point of the inventory sprite is at the center, which makes sense. But is there a way to offset the displayed text when the inventory cursor is active or how do I fix this?

https://imgbox.com/Mwl5IBRc
https://imgbox.com/jr9068O3

Comments

  • On a side note, your graphics look very nice...

  • Thanks, CamperJohn appreciate it!

  • edited April 2023

    Because you likely want the Hotspot menu's to make use of the Always fit within screen? property, you're probably best off relying on an alternative Hotspot menu - with the offset - that replaces the default while an inventory item is selected.

    You could handle the locking/unlocking of the correct menu through script:

    private void OnEnable ()
    {
        EventManager.OnInventorySelect_Alt += OnInventorySelect;
        EventManager.OnInventoryDeselect_Alt += OnInventoryDeselect;
    }
    
    private void OnDisable ()
    {
        EventManager.OnInventorySelect -= OnInventorySelect;
        EventManager.OnInventoryDeselect_Alt -= OnInventoryDeselect;
    }
    
    private void OnInventorySelect (InvInstance invInstance)
    {
        PlayerMenus.GetMenuWithName ("Hotspot").isLocked = true;
        PlayerMenus.GetMenuWithName ("HotspotInventory").isLocked = false;
    }
    
    private void OnInventoryDeselect (InvInstance invInstance)
    {
        PlayerMenus.GetMenuWithName ("Hotspot").isLocked = false;
        PlayerMenus.GetMenuWithName ("HotspotInventory").isLocked = true;
    }
    
  • I'd like to try that, but where would I attach this script? I don't have a lot of experience with the script side of things.

  • Create a new C# file named e.g. OffsetHotspotMenu, and place the code above inside the body of it (i.e. replace the default Start and Update functions with it). You can then place in the scene by attaching the new Offset Hotspot Menu component to a GameObject.

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.