I am trying to learn Unity 2D by going through some tutorial-book for a 2d RPG. Current chapter requires me to add a healthbar and an inventory. Healthbar worked immediately, but I am stuck with the inventory. The book wanted me to start with a new GameObject Inventory, which then has a child “Slot”, that in return has more children. Book then wanted me to split the Slot from the Inventory and create one Prefab for each (Inventory has another Child "Background). However, it does not tell me if I am supposed to instantiate both Slot and Inventory in the scene or only the first.
I can already add items to the slots and even the counter works fine, but for my life I am not able to move the slots to the upper left of the screen, it will always be at the center:
Is there anything obviously wrong that I am not seeing?
If it is any relevant: here is how the Inventory looks like. If I get it right, Slot and Inventory shouldn’t be connected any longer after I split them or is this a misunderstanding? Btw.: the Slot script does not contain anything about the position…
Analyzing the scene view, I noticed something that seems odd to me as a newbie (maybe it is not). The HealthbarObject, as well as the Inventory and Slot are huge compared to the actual scene (or the part of it I filled with sprites). Is this rather common?
Yes, the canvas will usually be much much larger when you double click on it. The canvas represents all of the UI that will be show on the screen, whereas the Camera will show your scene. Basically, the Canvas is (usually) static and overlays the camera.
I just started the whole process new, it is in the right position now, but the 2 Slots are overlapping. So I tried to fix this by playing with the Padding of the Instance of Inventory, but this has a very strange result, as it produces new/additional slots every time I change the padding and start Play-Mode:
Is this some bug? I also have to frequently re-start Unity, because Component fields are not accessible anymore or I can only delete values instead of entering new (that happened with the Padding field). Is there any way to prevent that from happening?
Thank you
For the future, you’re better off asking UI questions in the dedicated UI forums here. This forum is related to 2D features implemented by the 2D team. UI is a separate system by another team. Also, you’re more likely to get responses from devs regarding UI there.