简体   繁体   中英

Unity use UI panel in multiple different contexts

I have a panel that has 3 subpanel: Equipment, Inventory, Item Description.

Now I created the new panel that will have 2 subpanel: Shop, Inventory. Is there a way to use the same Inventory sub panel in both of the main panels?

I could just duplicate every action that happens with inventory to both of the panels. But it seems wrong. I think there should be a way to use the same panel in both of the situations(In store and out of the store);

The inventory panel is using the EventSystem, that allows easily to create Drag n Drop items in inventory. So duplicating it for both of the views creates a difficult scenario where when I drag the item out of the inventory of one panel it also needs to disappear in the other panel. So it needs some synchronization events or something.

I created the event using this https://youtu.be/c47QYgsJrWc

You can bring out the panels you need to reuse(like Inventory panel) from their parent panels and put them inside another panel naming like ReusablePanel .
And activate or deactivate the ReusablePanel when needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM