When I duplicate my UI, navigation stops working

Hello,

So, I am building an environment with NPC’s, every time I approach one of those characters and press a key I need UI to pop up in order to interact with them.

That works with one character but if I try to duplicate it and add it to another character the UI on both characters stop working. Any idea why or how to fix this?

I am essentially using a trigger that when I am colliding and I press a key I bring up buttons. I think the issue might be the event system but I am not sure. Please help!!

Don’t duplicate the event system - you only need one of those. Aside from that, how are you duplicating the UI, and what is interactive within the UI - for example, you have buttons? If so, then how are you handling that interactivity?

It depends on how you set up the interactive elements. If now you make a copy of them, yes, you may need some way to accommodate the new interactivity.

To help you further we need to see a more detailed view of how the UI is set up on an object, and the scripts that you have that get the interaction and the scripts controls or reacts to the interaction.

If I were attempting this, I would attach the Canvas as a child to the npc. I would have an event script on each button that would either send unique messages that a controller script on the npc would listen for, or the button would directly reference the controller script. That way when I duplicated the npc, it would have it’s own self contained UI system.

However, if the message / listener route would be more complex, because you’d have to ensure that a UI button click on NPC A was not received by the controller on NPC B. So with the message you’d need to send some kind of identifier with the message, and the controller script would parse out which NPC was reacting.

using these kinds of scheme, you shold be able to make as many copies of the NPC as you need.

I was able to figure it out. What I did was adding this line of code when I am not colliding with the NPC:

        EventSystem.current.UpdateModules();