Search Unity

[SOLVED] Textbox Scrolling Problem.

Discussion in 'UGUI & TextMesh Pro' started by CelticKnight, Nov 5, 2016.

  1. CelticKnight

    CelticKnight

    Joined:
    Jan 12, 2015
    Posts:
    378
    Hello Guys,

    I have ran into a problem and am hoping that I will be able to find some help here.

    I have set up a scrolling textbox that does work, it is of a small project that I am working with - it's part of a Unity course I am doing online. The course wanted you to just use a standard static textbox with programmatically changing text - so, I thought why not go an extra step and the box able to scroll when needed and dynamically change size depending on how much text is thrown into it.

    I tried using RectTransform component and the : sizeDelta=newVector2(); method, but, I found this code online and I'm not sure what the variable used are for, or, whether they will work. I get very unpredictable results, I just don't understand this code:
    • rt.sizeDelta=newVector2(rt.rect.width,text.preferredHeight);
    So would anyone be able to me whether what I am trying to do is easy enough to do or will it take a very in-depth knowledge to do it and leave it out for the time being and be happy with my scrolling box?

    Thanks and Regards,
    CK.
     
  2. CelticKnight

    CelticKnight

    Joined:
    Jan 12, 2015
    Posts:
    378
    Don't worry I've found a workaround for the time being.

    And Zeroing out the Anchor on the Top Centre of the Textbox to the Image Mask certainly helped where the text was being placed within the Textbox - it's amazing I didn't think of that sooner :oops:.