Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Layout Groups with UI Prefab Containers?

Discussion in 'UGUI & TextMesh Pro' started by ToastedShrimp, Apr 13, 2024.

  1. ToastedShrimp

    ToastedShrimp

    Joined:
    Jul 10, 2020
    Posts:
    6
    Hey guys. I'm currently working on an inventory system. Right now I have an InventoryCell prefab container which has a child canvas, which itself has 3 children with image components: a background, a border, and an item image. For the inventory GUI, I just want to add a bunch of these InventoryCell prefabs underneath a "CellContainer" that has a grid layout group for organization.

    This sounds very straightforward honestly, but the layout group isn't working and I suspect it's because the container for the prefabs does not have a rect transform. Is fixing this as simple as "making" the prefab root have a rect transform? Should I be giving the root a canvas element? a panel? I don't know if it matters, or if that's even the right approach. Thanks for any advice you guys can give.
     
  2. ToastedShrimp

    ToastedShrimp

    Joined:
    Jul 10, 2020
    Posts:
    6
    Well. I just found out you can simply replace the regular transform with a rect transform by adding a rect transform component. I've been using this engine for like 6 years and never knew that.