Today I started working on a inventory for containers , I am using the same code I used for the player inventory but the canvas element is´not placing in the correct place.
The canvas for the chest is a child of the “Chest” itself and the player inventory is the root (as you can see in the pic).
Could this be a problem?
It’ s hard to tell without knowing how you create your canvases. Anchors work using a relative scale of [0, 1], so if you want to make UI tree A look the same as B you need to either:
Make sure the parent hierarchy is the same. I.e.: If “Chest” is a [0.25, 0.75] x [0.2, 0.8] panel/ subcanvas, you’ll need a like-sized parent for your player inventory.
Adjust the anchors and offsets for the new parent (in this case, the canvas root).
If you drag your chest’s Inventory child onto the root canvas you can see the values needed for there, though you might want to reposition your anchors and clearout any offsets, depending on your implementation. (If you need to do this, this utility script might save you some time (be sure to follow the link to the updated version).)
Hope this helped a bit. If not, please let us know exactly how you’re setting things up and such. =)