Unity Tutorial Auto scaling image to fit the length of the text using Unity UI. NO CODE, super easy!

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 ต.ค. 2024

ความคิดเห็น • 83

  • @BGFutureBG
    @BGFutureBG 2 ปีที่แล้ว +27

    Note you can actually have a dynamically sizing box *both* vertically *AND* horizontally without making explicit line breaks in the text! Though the setup is not quite straight forward.. Using the hierarchy in this video:
    - Container: ContentSizeFitter with *HorizontalFit unrestricted* and *VerticalFit prefferedsize* , VerticalLayoutGroup with ControlChildSize for both width and height *BUT no ChildForceExpand set*
    -- ImageSpeechBubble: VerticalLayoutGroup with ControlChildSize for both width and height *BUT no ChildForceExpand set*
    --- Text(TMP): Plain text element, *NO LayoutElement or ContentSizeFitter components!*
    If the layouting stuff in unity had MaxWidth and MaxHeight properties, things could be a lot easier and more straight forward...

    • @DestinedToLearn
      @DestinedToLearn  2 ปีที่แล้ว +1

      Thanks :) The unity UI is powerful but tricky at times. I pinned this so people will notice.

    • @BGFutureBG
      @BGFutureBG 2 ปีที่แล้ว +1

      @@DestinedToLearn Oh nice, glad to help :)

    • @DestinedToLearn
      @DestinedToLearn  2 ปีที่แล้ว

      @@BGFutureBG :)

    • @wurstautomat832
      @wurstautomat832 ปีที่แล้ว +3

      I love you! content size fitter stuff is not very intuitive :/

    • @originaldoku
      @originaldoku 11 หลายเดือนก่อน +1

      @@BGFutureBG Thanks man, I was looking for this exact thing online and couldn't find it until your comment :)

  • @Anakox
    @Anakox 5 หลายเดือนก่อน +1

    The best tutorial on this topic. I couldn't make it work properly before, just tried random stuff until it kinda worked, and now I understand how to do it.

  • @MondoMurderface
    @MondoMurderface 6 หลายเดือนก่อน

    Finally.. A video that shows how the scaling elements relate to each other. I was trying forever to get it to only scale up and not down. Every other tutorial completely skips over the pivot points and why you want it to be set to center bottom/top. Thank you!

    • @DestinedToLearn
      @DestinedToLearn  6 หลายเดือนก่อน

      I am glad it helped, honestly I made this tutorial so I wouldn't forget next time i needed to do it!

  • @cristianfernandez9708
    @cristianfernandez9708 ปีที่แล้ว +1

    I had problems at first but it end up working, thank you so much

    • @DestinedToLearn
      @DestinedToLearn  ปีที่แล้ว

      glad you got it figured. It is a bit tricky.

  • @PaulLovato
    @PaulLovato 10 วันที่ผ่านมา +1

    You're a legend.

  • @CESRex21
    @CESRex21 ปีที่แล้ว +1

    Thanks a lot

  • @botansahin
    @botansahin หลายเดือนก่อน

    What if the parent of this container also has verticallayoutgroup, it gives "parent has layout group" error, I want speech bubbles the layout vertically also

  • @WorldAquariumSingapore
    @WorldAquariumSingapore ปีที่แล้ว +2

    Cheers keep up e good works

  • @2MARR8
    @2MARR8 3 ปีที่แล้ว +2

    You have saved my sanity, thank you!

    • @DestinedToLearn
      @DestinedToLearn  3 ปีที่แล้ว

      Glad it helped. When I first did this is was a bit annoying to setup. I actually made the tutorial to remind future me how to do it.

  • @macawls
    @macawls 2 ปีที่แล้ว +1

    Thank you so much. I was in unbearable pain.

    • @DestinedToLearn
      @DestinedToLearn  2 ปีที่แล้ว

      I feel you. I went thru that figuring a system which worked well for me! I made the tutorial so i didn't forget what I did because I need it every now and then.

  • @anna_8613
    @anna_8613 2 ปีที่แล้ว +4

    Very clear and helpful tutorial! Thanks a lot!! ^^

  • @keon-kuk1393
    @keon-kuk1393 ปีที่แล้ว +1

    Thanks very much xD. You save my time and life.

  • @christinelazarus1614
    @christinelazarus1614 2 ปีที่แล้ว +1

    THANK YOU

  • @sujeto9402
    @sujeto9402 2 ปีที่แล้ว +1

    Maaaan!! you are the best!! Thank you!

  • @avery_person8126
    @avery_person8126 ปีที่แล้ว +1

    well explained and helpful, thanks

  • @vincentmeessen6659
    @vincentmeessen6659 2 ปีที่แล้ว +1

    Perfect tutorial, really clear and helpful thx ;)

  • @Shining4Dawn
    @Shining4Dawn 2 ปีที่แล้ว +1

    The moment I set the Empty Game Object's Content Size Fitter Vertical Fit property to Preferred Size - it's Height value changes to match the image's pixel size, and unless that is smaller than the size you need, it will not look good. I tried changing Vertical Fit to Min Size or setting the image's Preferred Width or Preferred Height values by adding a Layout Element component to it brings the image back to it's desired size but it prevents the text from resizing the image, making the whole process meaningless.
    Eventually, I ended up changing the Empty's scale to 0.25 on all axes and multiplying the font size by 4.

    • @DestinedToLearn
      @DestinedToLearn  2 ปีที่แล้ว +1

      glad you got it fixed in the end. Unity UI is weird sometimes

    • @Shining4Dawn
      @Shining4Dawn 2 ปีที่แล้ว

      @@DestinedToLearn Yeah, it took a lot of fiddling.
      I should also mention that it's really useful to switch the Canvas object to render in World Space. I'm currently building a UI over a mockup and switching the Canvas to World Space allows me to accurately place the UI elements in their desired locations. It also prevents elements from moving around when rescaling the screen, which was a major issue in my case.
      I haven't found a downside to working in World Space, but I bet it's just a matter of time. Otherwise, this'll be my way of working with Canvas objects for every project from now on.

  • @eriknastesjo843
    @eriknastesjo843 2 ปีที่แล้ว +1

    Thank you! Liked, subscribed and commented :D

  • @mairinger80
    @mairinger80 2 ปีที่แล้ว +1

    Fantastic stuff!

  • @gamoe
    @gamoe 2 ปีที่แล้ว +1

    thanks you

  • @Omwekiatl
    @Omwekiatl 2 ปีที่แล้ว +1

    very usefull

  • @KomalGupta-fp4ny
    @KomalGupta-fp4ny 2 ปีที่แล้ว +1

    Very helpful! Thank you for posting this :)

  • @fulconini
    @fulconini 2 ปีที่แล้ว +1

    Super usefull thank you1!!

  • @jirikaminsky9851
    @jirikaminsky9851 3 ปีที่แล้ว +1

    Could you make a tutorial how to spawn the bubles , in such way that if new bubble is spawn the old one moves up like in chat games

    • @DestinedToLearn
      @DestinedToLearn  3 ปีที่แล้ว

      oh you mean like phone messages? What chat games are you referring too?

    • @nguoidanhthuguielise
      @nguoidanhthuguielise 3 ปีที่แล้ว +1

      @@DestinedToLearn Thank you for the content, I'd be interested to know as well! Mystic Messenger came to mind, but any chat simulator interface would be just as helpful

    • @DestinedToLearn
      @DestinedToLearn  3 ปีที่แล้ว +1

      @@nguoidanhthuguielise I had to look that up, but that isn't too hard. I will put it on the list. It is pretty much the same as a notification system.

    • @anna_8613
      @anna_8613 2 ปีที่แล้ว +1

      Yeah, I'm also looking for a way of incorporating a chat in a game!! So that the chat boxes move up with time. Would be so helpful

    • @DestinedToLearn
      @DestinedToLearn  2 ปีที่แล้ว

      @@anna_8613 I have some time this week so I will try and make this since two people now want it :)

  • @amanverma6469
    @amanverma6469 3 ปีที่แล้ว +1

    Thanks for the tutorial !

  • @KnowInDetails
    @KnowInDetails 2 ปีที่แล้ว +1

    Thank You man!

  • @marceljelinski3639
    @marceljelinski3639 ปีที่แล้ว

    Hi! Thanks for the tutorial :D Is there any way to expand whole thing upwards, not downwards?

    • @DestinedToLearn
      @DestinedToLearn  ปีที่แล้ว

      it is, you need play with the pivot points. I haven't done it but you want to change the pivot to be at the bottom not the top.

  • @mendalosindiedevrpg8084
    @mendalosindiedevrpg8084 2 ปีที่แล้ว

    Very simple and good tutorial. Thank you

  • @taxol1016
    @taxol1016 2 ปีที่แล้ว +1

    Really helpful!

    • @taxol1016
      @taxol1016 2 ปีที่แล้ว +1

      Achieving this effect has been bothering me for a long time, and I'd appreciate it if you'd go a little deeper into why you use these components and how they work. Your tutorial is good, thank you very much!

    • @DestinedToLearn
      @DestinedToLearn  2 ปีที่แล้ว

      @@taxol1016 glad it helped :)

  • @Vagossssssssss
    @Vagossssssssss 2 ปีที่แล้ว +1

    Thank you so much

  • @harshvardhanmisal2255
    @harshvardhanmisal2255 2 ปีที่แล้ว +1

    Thanks 😁

  • @hangry_demure
    @hangry_demure 3 ปีที่แล้ว

    Thanks!

  • @jirikaminsky6397
    @jirikaminsky6397 3 ปีที่แล้ว

    Tank you Very much

  • @etrex5272
    @etrex5272 9 หลายเดือนก่อน

    I have a game with over 20 000 lines of code and the most advanced systems. But I can't get the content size fitting and Unity UI to work how I want it to. It's so badly designed every time I do UI work its just guesswork and trial and error. I give up once again, I'm diving into visual studios to solve this aswell aswell. Lmfao!

    • @DestinedToLearn
      @DestinedToLearn  9 หลายเดือนก่อน

      indeed i feel it is a dark art too. I made this so i wouldn't forget how I made it work lol

  • @voidling2632
    @voidling2632 2 ปีที่แล้ว +1

    As for know, you can forget this, it's broken it does not work. The image isn't scaling at all.

    • @DestinedToLearn
      @DestinedToLearn  2 ปีที่แล้ว

      You probably just missed a step, it is tricky to setup. Plenty of people have got it working with no problem.

    • @voidling2632
      @voidling2632 2 ปีที่แล้ว +1

      @@DestinedToLearn I got it to work... but with several other issues with no solution in sight. It got me way too frustrated, so I ended up writing a script for it.

    • @looopy1
      @looopy1 2 ปีที่แล้ว

      @@voidling2632 can you share the script