Search Unity

Change submenus rect transform to match Canvas

Discussion in 'UGUI & TextMesh Pro' started by MayoNinjaGames, Nov 25, 2018.

  1. MayoNinjaGames

    MayoNinjaGames

    Joined:
    Nov 7, 2018
    Posts:
    31
    So I followed Brackeys tutorial on how to create menus for my game (link), but I'm having a problem with different screen sizes when creating submenus. He places all his different buttons and gameobjects under one gameobject, which he then activates and deactives to open different submenus.

    My problem is that when I create a empty gameobject, set the height and width to the canvas' height and width, but then change the screen sizes, the buttons goes out of bounds. I'm guessing it's because the rect transform of the empty gameobject doesn't change with the canvas' rect transform. If I just place all the buttons under the canvas directly, everything works.

    So I guess I just have to make a script to set the rect transform to match the canvas size, but I can't find the variable to use or set. :/
     
  2. MayoNinjaGames

    MayoNinjaGames

    Joined:
    Nov 7, 2018
    Posts:
    31
    Never mind! Found out that there was a button for stretching out the rect transform to match the parent in the Rect Transform Component!