LeanTween.MoveY unexpected results on different devices

  Uncategorised

I’m using LeanTween for animating my UI. Everything works fine except for an unexpected behavior using the MoveY() method.

Basically what happens is that the movement on the Y axis results different if I change device.

public void ShowAnimation(float position)
{
    LeanTween.cancel(this.gameObject);
    LeanTween.moveY(this.gameObject, position, 0.7f);
}

Let’s suppose I call the method using ShowAnimation(100.0f), this is what it happens:

iPhone X/XS (2436x1125) -> Moves the gameObject to 110.37f
iPhone XS Max (2688x1242) -> Moves the gameObject to 100.00f
iPhone (1334x750) -> Moves the gameObject to 182.66f

But… if I change the method adopting the value() method everything works fine.

public void ShowAnimation(float position)
{
    LeanTween.cancel(this.gameObject);
    LeanTween.value(this.gameObject, MoveObject, 0.0f, position, 0.7f);
}

void MoveObject(float position)
{
    this.GetComponent<RectTransform>().anchoredPosition = new Vector2(0.0f, position);
}

Any help? I don’t know why this happens.

Edit: as long as I read, the issue seems related with the Canvas Scaler. Any workaround?

Source: Visual Studio Questions

LEAVE A COMMENT