Forum rules - please read before posting.

Scroll Rect on UI issue

edited January 2020 in Engine development

Hi, so I have a strange setup that works 90%. Only one issue:

I am using one Unity UI menu.
The main panel has a scroll rect and a few buttons.

That menu works for both my inventory and my conversation. The same buttons work as inventory item in one, and dialogue options in the other.

Probably not best practice to link the same Unity UI menu objects to multiple AC menu elements, but it works great.

Except for one thing: the Scroll Rect position.

I open the inventory and scroll to position 1. Close inventory. Reopen it and the transform is saved. Works fine.

But if I open the conversation menu, the position is reset.
Weird thing is that if I scroll around in the conversation menu to position 2, close and reopen it, the second transform is also saved.
I reopen the inventory it's on position 1.
I reopen the conversation and it's on position 2.

So there's two different scroll rect transforms stored in memory somehow - I'd love to be able to make it the same for both menus. Any ideas how that could be achieved?

Comments

  • I'm not clear if these are two separate menus, that share the same UI prefab, or if a single menu/prefab shows both Conversation and Inventory.

    If the menus are separate, then both menus will spawn their own instance of the UI prefab - meaning there are now two UI objects, each with their own Scroll Rect.

    The Scroll Rect itself isn't controlled by AC, but you could hook into the OnMenuTurnOff custom event to read the value of the one that's closing to update the one that isn't.

    From that event, you can read the Menu's RuntimeCanvas property to then find the ScrollRect inside it's hierarchy.

  • Oh I see, thanks for the quick reply. It's two separate menus that share the same UI prefab.

    I'm not super comfortable with custom events yet but will look into it.

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.