Search Unity

Line renderer scaling

Discussion in 'Scripting' started by TheGrovesy, Oct 19, 2020.

  1. TheGrovesy

    TheGrovesy

    Joined:
    Jan 8, 2013
    Posts:
    25
    I am using a line renderer to create a mouse drag/drop line (the line starts at the mouse down event and draws to the current mouse position until the mouse button is released). Until now I have just been testing on PC and I have hardcoded the maximum line length (300) so its around 2/3 the screen height which works for my setup.

    I have now tried this on a mobile phone and this hardcoded max value is only allowing a very short line, around 1/6 the screen height.

    How can i limit my line to be 2/3 the current device screen height?

    thanks
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    You can multiply Screen.width or Screen.height by some factor like 0.66f.
     
  3. TheGrovesy

    TheGrovesy

    Joined:
    Jan 8, 2013
    Posts:
    25
    Many thanks. This worked a treat :)