Help with recttransform lerp , lags on mobile not on pc.
Why is this code lagging on my mobile ( android ) ,whenever it runs and not on my pc? . Please help anyone!!
public void AboutBtn() { StartCoroutine(about()); }
IEnumerator about()
{
float elapsedTime = 0f;
float lerpDuration = 1f;
menuBool = true;
menuBarAnim.Play("menuBarAnimationB");
sidebarAnim.Play("SideBarAnimB");
Vector2 Origin = MoverR.anchoredPosition;
Vector2 Destix = new Vector2(Origin.x, -3658); //replace 6050 with the position you want
while (elapsedTime < lerpDuration)
{
elapsedTime += Time.deltaTime;
MoverR.anchoredPosition = Vector2.Lerp(Origin, Destix, elapsedTime);
yield return null;
}
anim = false;
menuBool = false;
}
That code alone shouldn't be a problem in mobile, maybe you have low framerate all the time but you only noticed when doing an animation.
You should profile your game. You can build and run into your device directly from Unity and then use the profiler to get runtime stats of your game. You can trigger the lerp and see what's the CPU doing during the lerp.
Got 2 devices - Samsung galaxy tab s 8.4 and Xperia $$anonymous$$
Lag is a little on tab and really bad on xperia m , I only have lag when the lerp starts in mobile and not on pc. I will check the profiler right now.
Click over some of the blue areas in the CPU line, and you'll see what methods are causing that in the bottom half of the window.
Answer by manhuntz111 · Aug 26, 2016 at 02:08 PM
Nevermind , solved it . The problem was the canvas had pixelperfect (true) , making it false doubled the performance no lag now. :)