Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Making the UI canvas float in the middle at all times.

Discussion in 'UGUI & TextMesh Pro' started by moynzy, Feb 22, 2015.

  1. moynzy

    moynzy

    Joined:
    Oct 22, 2014
    Posts:
    82
    Any way to make the Canvas be in the middle at all times?

    Basically, I want the canvas to fit the screen. But when I change resolution from 720, to 1080. The canvas floats to the left. Plus how can I make sure the position of a UI element will always stay in once place regarding the resolution?

    For example, if I put a health bar in the left hand corner at 1024 * 720, then change the perspective to a bigger size, will the health bar stay there?
     
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    Anchors are used for positioning / stretching of your UI. So you will need to adjust your anchor points to get the effect you want.
     
  3. moynzy

    moynzy

    Joined:
    Oct 22, 2014
    Posts:
    82

    OH! So the main canvas, the anchor point will be in the middle?

    And all corners will be stretched, and in theory, this should make the parents, such as the panel do the same?
     
  4. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    In Screen Space Canvases (overlay and camera) take up the full screen already.
    For the UI to stay exactly where you want it, then yes, put the anchors to all the corners.

    Be sure to also use a Canvas Scalar mode if you intend to use it on multiple resolutions.