Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

GUI text stretching

Discussion in 'UGUI & TextMesh Pro' started by KrisBendix, Jun 15, 2015.

  1. KrisBendix

    KrisBendix

    Joined:
    May 26, 2015
    Posts:
    15
    Hi.
    Made all of the UI buttons and everything. Finally got it to work with multiple resolution and aspect ratios.
    Made them by using canvas and everything that comes with it. Works as I intended.
    Now the problem is that GUI text (that is not displayed on canvas) doesn't go along with everything else... getting hidden under UI buttons etc. when aspect ratios are changed.
    I can fix the "go along with everything else" problem by unchecking pixel correct, but now it warps the text. I can fix the warped text for specific aspect ratio, but as soon as the ratio is changed, the text stretches along the x or y depending on how that aspect ratio was changed.

    One solution might be to make that score, health, energy text in canvas scaler, but as soon as I use it on GUItexts the texts disappear.

    This is the script that gives value to score text for instance:
    Code (CSharp):
    1. void UpdateScore ()
    2.     {
    3.         scoreText.text = score + "";
    4.     }
    May be you can put me in right direction how to display score etc. by using canvas and UI that way? If it is even possible.
    Or simply prevent that GUIText from not going along with everything else and stay unstretched as if pixel correct is on?
     
  2. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,256
    How are you setting up the Canvas?

    I make all my canvases use the scaler set to scale with screen size. I then pick a size like 1920x1080 or 1280x720 to use as a reference resolution. After that I have to adjust the size of some components on the canvas so they are the right size and visible. Usually I setup the scaler before adding components to it, so I avoid the resizing of any components on the canvas.
     
  3. KrisBendix

    KrisBendix

    Joined:
    May 26, 2015
    Posts:
    15
    Got it to work somewhat again with (scaleOnRatio1.x, widthHeightRatio * scaleOnRatio1.y, 1) and stuff, but still having problem on different aspect ratios - positions.
    I think I will stop using that old GUI thing. Causing too much problems.
    Now I only have to find a good way to convert my scripts to new UI.

    I am having no problems with new UI system where I have buttons and menus on.
     
  4. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,256
    I think the people at Unity, wanted you to use the new UI for game stuff and the old UI for editor scripts. I would advise against using the old for anything but editor scripts, the performance can be horrible. Once you get used to the new UI's nuances, its really a much better system.