Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    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. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    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:
    64
    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:
    64
    When I said "row" above, I meant "cell" .... blush!
     
  3. leftshoe18

    leftshoe18

    Joined:
    Jul 29, 2017
    Posts:
    16
    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:
    64
    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.