Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[SOLVED] Placing a Button

Discussion in 'UGUI & TextMesh Pro' started by christinanorwood, Mar 18, 2015.

  1. christinanorwood

    christinanorwood

    Joined:
    Aug 9, 2013
    Posts:
    402
    I have a button in my 2D game, but I seem to be missing something obvious with respect to its placement. In the scene view the Canvas and the button don't relate to the scene at all (much larger, different placement), and with trial and error I managed to place the button so that it shows in the game in the right place but it does't show in the Game View in the right place. Is there any way to have these all appear in the same place in the Scene view, game view and actual game?

    Button.jpg

    ETA I think I've worked it out somewhat. The game is set to standalone 1024 x 768, but in the Game View it's using 573 x 430. If I don't check maximize on play then when I play (in the game view) it stays put, but if I Maximize on Play then in the standalone window it's in the wrong place because the window has changed size but the button hasn't moved.

    This still leaves me with the problem of how to place the button visually. Seems trial and error is the only way to go.
     
    Last edited: Mar 18, 2015
  2. Feaver1968

    Feaver1968

    Joined:
    Nov 16, 2014
    Posts:
    70
  3. christinanorwood

    christinanorwood

    Joined:
    Aug 9, 2013
    Posts:
    402
    Thanks, I tried that, but it doesn't seem to make any difference.
     
  4. christinanorwood

    christinanorwood

    Joined:
    Aug 9, 2013
    Posts:
    402
    OK, I found a solution. I have created a new layout with just the Game view, plus the scene view as a floating window. The Game view shows at full res, and I can pan the scene view 'til I find the button and then move it, watching its position in the Game View 'til it's in the right spot.
     
  5. christinanorwood

    christinanorwood

    Joined:
    Aug 9, 2013
    Posts:
    402
    You were right - it didn't work for me originally because I hadn't assigned the main camera to the appropriate field for the Canvas in the Inspector, but when I did that the button maintained it's relative size and position in the Game View whatever resolution that was.
     
    Feaver1968 likes this.