Search Unity

UI Panel with image moving from off screen onto screen and off again.

Discussion in 'UGUI & TextMesh Pro' started by codejoy, Aug 6, 2016.

  1. codejoy

    codejoy

    Joined:
    Aug 17, 2012
    Posts:
    204
    I have this panel with an image off to the side of my screen, and when a collection happens I want it to animate onto screen and slide off again. I have the animation up and running and it all works but the coming in from off screen changes. I develop on two different computers and sometimes when i start the game the UI panel is on screen already. On the other PC its off screen. If I move the dev scene windows around it changes. How can i start the panel to the right edge of the screen and make sure the animation (a simple move to the left then to the right off scene again) happens consistently anytime. I am not even sure what code/ or screenshots to post.
     
  2. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    The problem might be the different resolutions.
    A easy way to work around that is to animate the anchor instead of the actual position.
    That way its allways a percentage of the screen size and not a fixed pixel amount.
     
  3. codejoy

    codejoy

    Joined:
    Aug 17, 2012
    Posts:
    204
    I am a bit new as to animating UI elements like this. I am showing the animation here (see image) It Says the anchored position is what is changing. If I have that panel off screen it changes each time as to the start and I have to even reset the animations it seems.
     

    Attached Files:

  4. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,187
    Usually if you have different resolutions, and you want it to stay on the side (offscreen) you'll want to anchor it on that side. The other thing you'll need to do I believe is also check your canvas. You have a canvas scaler on the canvas. Setting it to scale with screen size and setting a reference resolution plus a match will also be required for it to "scale" depending on your resolution on different devices or monitors/computers.