Search Unity

UI Scaling bug or am i missing something?

Discussion in 'Unity UI & TextMesh Pro' started by fede998, Nov 10, 2018.

  1. fede998


    Oct 15, 2018
    I'm kinda new to Unity and im following a series of video about creating a rpg battle system but i ran into a problem with the GUI.
    Here's the problem: I have to fill a panel with buttons automatically using scripts and buttons' prefabs but, as long as i put buttons' prefabs in the gameobject(which resize them for the panel) by dragging the prefab into the gameobject in the hierachy everything works fine.
    Here's the photo:
    The problem begins when unity has to do it automatically.
    I followed the video and im using the same script but when the buttons are automatically created in the gameobject they are not sized correctly.
    Here are the photos which show the difference:
    Well, i have to say it worked fine since in another video i had to change the Canvas scaler from "constant pixel size" to "scale with sceen size" to fit the heroes information.
    Now i'm in a kind of limbo where if i keep "scale with sceen size" the enemy panel works bad and if i use "constant pixel size" the hero panel has troubles.
    Hope u have some good tips and im sorry if it's not a perfect English, for any informations you are free to ask.
    Last edited: Nov 10, 2018
  2. Hosnkobf


    Aug 23, 2016
    I also had a lot of problems with the canvas scaler options. It never worked the way I wanted...
    That's why I created Better UI. Sorry that I cannot give you advise how to solve it with UGUI alone.