Layout group make Object smaller ...How fix that?

Hi everybody ! I want to do a simple Vertical Grid Layout Group for a list of sentence.

When i am in the editor and i put manually object in the Grid layout group, All is ok !

But if i’m instanciate this text object in the game , the size of the object become smaller …

I had already set the canvas to Screen size but nothing change :confused:


If someone can help me i’ll really appreciate !:slight_smile:
Have a good day !

After instantiating the game object, set the scale to Vector3.one
I think it will solve your problem.

If what MiladZarrin1 says dosn’t fix your problem ,try maybe to add your prefab manually as a child of your vertical layout group. Then, once it has the right size, create a new prefab using this object, instantiate that new prefab instead of the old one.
In French : Si ce que MiladZarrin1 ne donne pas le résultat escompté, essaye peut-être d’ajouter ton prefab manuellement en child de ton vertial layout group. Une fois qu’il a la bonne taille, recrée un prefab en utilisant l’objet ayant la bonne taille, puis instantiate ce nouveau prefab.

If that still doesn’t work, i believe you need to modify the pivots.

@hlw Thanks for youre answer, i have already try do this but nithibg change:/

How can i set the scale like said @MiladZarrin1 ?

Thanks for youre help !

For an accurate answer I need your Instantiate Code. But it generally goes like this:

GameObject g = (GameObject)Instantiate(...);
g.transform.localScale = Vector3.one;

Okay thanks ! here my instanciate’s code! :slight_smile:

public  void AddInfoUI(string UIInfo)
    {
          GameObject InfoObject = Instantiate(InfoPrefab);
          InfoObject.transform.SetParent(PanelInfoUI.transform);
          InfoObject.transform.GetChild(0).GetComponent<Text>().text = UIInfo;
    }

Just add this line at the end of your code:

InfoObject.transform.localScale = Vector3.one;

I think it will solve your problem. let me know the result.

1 Like

Okay thanks ! I will test that tonight and I’ll come back to you !
Thanks for youre help!

Thanks à lot ! This is work now perfectly !

Have a good day !:slight_smile:

You’re quite welcome my friend. You have a nice day too :slight_smile: