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

Screen Space - Overlay & Canvas Scaler & _ScreenParams potential issue

Discussion in 'UGUI & TextMesh Pro' started by Stephan-B, Jan 9, 2015.

  1. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I have an issue where when the Canvas is set to Screen Space - Overlay and a Canvas Scaler is used and set to Scale Width Screen Size mode, the shader _ScreenParams appears to not be reflecting what is the correct width & height.

    If I change to Screen Space - Camera and assign the main camera then everything is fine. However, if I don't assign the main camera, the issue returns.
     
  2. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I would appreciate some feedback or insight on this please.

    I am using _ScreenParams to compute the Pixel scale in my Shader but when a Canvas Scaler is used in Screen Space - Overlay or Screen Space - Camera and no camera is referenced, it appears the geometry is scaled internally by Unity while this scaling is not reflected in _ScreenParams. I can compensate for this by checking if a Canvas Scaler is used and if a Camera is referenced at which point I ignore the lossyScale in my computation but I then end up with a clean looking object in the GameView but potentially an object too soft or too sharp in the editor since we now have two scales.

    I am just trying to figure out how I should be handling this Canvas Scaler.
     
  3. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    I'll ask around because i have NO idea...
     
  4. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Thanks Phil :)
     
  5. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,870
    I don't understand what the problem is. _ScreenParams is documented like this:
    This is unrelated to anything in the UI system.

    The CanvasScaler sets the Canvas scaleFactor, which in the end just adjusts the localScale of the Canvas GameObject. There is no internal scaling other than this regular scaling of a GameObject.