What's the proper way to Set/UnSet PanelOwner?

filod

Member
as the title suggests, if my character dies, then i need destroy the character and respawn it, my assumption is call `InventoryCanvasPanelManager.SetPanelOwner` when after new character spawn. but i found that `ItemHotbar` won't bound/unbound inventory automatically, after open the UI menu, it will throw error like this:
1692377741618.png
 
Normally calling SetPanelOwner should have done the trick.
This sounds like it could be a bug.

I had a look at the code and I don't see why it wouldn't work. calling the SetPanelOwner function on the panel manager forces all the panel to be reinitialized. This forces the bindings to be reinitialized too. And it should rebind the input.

I'm afraid will need more context to be able to figure this out.

Also just to be sure, do you have to destroy your character? Usually characters are never destroyed. They are simply disabled and then reanabled when they spawn back. That not only could fix this issue, and make your game more performant. But it could also prevent other issues that can arise from destroying objects.
 
Normally calling SetPanelOwner should have done the trick.
This sounds like it could be a bug.

I had a look at the code and I don't see why it wouldn't work. calling the SetPanelOwner function on the panel manager forces all the panel to be reinitialized. This forces the bindings to be reinitialized too. And it should rebind the input.

I'm afraid will need more context to be able to figure this out.

Also just to be sure, do you have to destroy your character? Usually characters are never destroyed. They are simply disabled and then reanabled when they spawn back. That not only could fix this issue, and make your game more performant. But it could also prevent other issues that can arise from destroying objects.

Ah , that's a great suggestion, i destroy it just because it's convenient.

The bug may rooted in ItemUser&UnityInputSystem? or maybe just hotbar issue?

i do found that HotBar is bounded to inventory (the items can be seen), but i can not interact it with input, and then when open MainMenu, the error above shows up, but then the input functions right.
 
Top