简体   繁体   English

Unity在多个不同的上下文中使用UI面板

[英]Unity use UI panel in multiple different contexts

I have a panel that has 3 subpanel: Equipment, Inventory, Item Description. 我有一个包含3个子面板的面板:设备,库存,项目描述。

Now I created the new panel that will have 2 subpanel: Shop, Inventory. 现在,我创建了一个新面板,该面板将包含2个子面板:商店,库存。 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. 库存面板使用的是EventSystem,可轻松创建库存中的Drag n Drop项目。 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 我使用此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 . 您可以从其父面板中取出需要重用的面板(例如Inventory面板),并将其放在另一个面板中,例如ReusablePanel
And activate or deactivate the ReusablePanel when needed. 并在需要时激活或停用ReusablePanel

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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