Search Unity

Inconsistent game object placement/size between two people

Discussion in 'Editor & General Support' started by Greyvenn, Jun 22, 2021.

  1. Greyvenn

    Greyvenn

    Joined:
    Feb 3, 2019
    Posts:
    5
    Hello all,

    A friend and I are developing a mobile game together, and we noticed that the sizes of our UI canvases are different, even though we are working from the same source code and project (We are collaborating with git). On my screen, the canvas is significantly larger, and the UI elements placed on it are much smaller in the game view compared to her's, where they are much bigger. They also show up in different positions on the screen.

    The only difference I can think of is that my side is set up to test on android, and hers is set up for iPhone. She tried switching to android development, but the canvas size didn't change, so I'm not sure if that is the issue. Is there something we are missing in order to get the same canvas ratio?
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    If it's a screen space canvas, the size of the canvas is always the resolution of the screen/game viewport. The difference is most likely due to you and your friend having different screen resolutions.

    You'll want to both get very familiar with the concepts in this article in order to layout your UI properly: https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/UIBasicLayout.html
     
  3. Greyvenn

    Greyvenn

    Joined:
    Feb 3, 2019
    Posts:
    5
    Excellent, we'll read up on it. Thanks for the very fast reply!
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,686
    It can be very fiddly but it is super-powerful once you reach comfort with the UI.

    Building upon Praetor's great post above, let me suggest this approach:

    - make a quick first draft of your UI.
    - in the Unity game window change the shape / dimensions of your Game window (you can even make your own resolutions)
    - see what happens to your UI in this new shape window
    - iterate and fix your anchors and scalings and whatnot

    Make sure you do not overlook the Canvas Scaler settings. Personally I (almost) always use Scale with Screen Size and Match Width Or Height, with 100% height because it seems the most useful. I also NEVER change the 800x600, which lets me copy/paste prefabs between any of my projects trivially.

    Screen Shot 2021-06-22 at 12.02.31 PM.png
     
    vSwaize and CodeRonnie like this.