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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Aspect ratio problems with particle systems on canvas

Discussion in 'UGUI & TextMesh Pro' started by QFSW, Aug 4, 2015.

  1. QFSW

    QFSW

    Joined:
    Mar 24, 2015
    Posts:
    2,905
    Hi all, I have a very very annoying problem which I have been trying to fix forever but I just cannot find a way to fix it

    So to explain what I have going, I have a bar which shoes how much of your power up you have left, this has its origin in the far left and it scaled along the x axis to show how much is left. Parented to the bar (on scale 1) on the right side is a particle system, this then always stays on the edge of the bad as it scales.

    I hade to change this to a world space canvas otherwise the particle system just wouldn't position properly no matter what I tried.

    This world space canvas also has a vertical boost gauge on the left side of it, as that used a particle system too

    Now here's the problem, when you change the aspect ratio the world space canvas does not adjust, hence things overlap and go out the edge

    I've tried using the aspects ratio fitter but then the particle systems break again

    Does anybody know any way you fix it? So that I can have particle systems on an canvas which properly resizes
     
  2. QFSW

    QFSW

    Joined:
    Mar 24, 2015
    Posts:
    2,905
    Don't worry guys, found a solution, very messy one where I calculated linear lines of regression and made the code use them to position stuff but works nevertheless
     
  3. WimLI

    WimLI

    Joined:
    Mar 31, 2015
    Posts:
    9
    what your solution?
     
  4. QFSW

    QFSW

    Joined:
    Mar 24, 2015
    Posts:
    2,905
    Essentially what I did was I went to 5 different aspect ratios. At each one I noted down the aspect ratio (as a single number. 16:9 was something like 1.7....) then moved the gauge to the right until it looked how it originally did and noted down the position. I tried plotting these values against each other and found they had a linear relation ship, so I used some A Level maths and calculated a linear line of regression from it. I put this formula in the code, using it it would calculate the desired position based on the aspect ratio
     
  5. DeveloperKuuasema

    DeveloperKuuasema

    Joined:
    Dec 23, 2013
    Posts:
    1