Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Using a Grid with composite prefabs

Discussion in 'Unity UI & TextMesh Pro' started by dogfacedesign, Nov 5, 2018.

  1. dogfacedesign

    dogfacedesign

    Joined:
    Jan 10, 2016
    Posts:
    70
    I posted this originally in the wrong forum, as I didn't see the UI subforum at first. I have requested an admin delete the original, so recreating it here in hopes of soliciting some guidance from Unity/UI gurus out there.

    So I have a test grid set up, and it works fine with single items in each cell (image, text, etc.). But, if I try to put something in there like a prefab that has an image and a text label in it, it doesn't seem to work (they all sort of stack up on top of each other instead of being spread out in the grid).

    When I say "composite prefabs", I mean prefabs with more than one GameObject in it. For example:

    GameObject (just a Container or "row")
    ---- GameObject (Image)
    ---- GameObject (Text/Label)

    Is this normal behavior for the grid component? Thanks in advance for any suggestions/guidance!
     
  2. dogfacedesign

    dogfacedesign

    Joined:
    Jan 10, 2016
    Posts:
    70
    When I said "row" above, I meant "cell" .... blush!
     
  3. leftshoe18

    leftshoe18

    Joined:
    Jul 29, 2017
    Posts:
    34
    It sounds like your prefab isn't set up properly. I use this method for most of my dynamically generated UI elements and haven't had any problems.

    How is your container set up? How are the child objects anchored?
     
  4. dogfacedesign

    dogfacedesign

    Joined:
    Jan 10, 2016
    Posts:
    70
    They have relative offsets to the cell container, I would think they would be fine. I will explore it further - anchoring may indeed be necessary.