Backround roll
Hi i have a sea backround and clouds in my 2d game they are rolling all the time by making the sprite Wrap mode Infinite and adding it to a 3d Cuad and this script (THIS IS THE METHOD https://www.youtube.com/watch?v=HrDxnMI7pCc)
using UnityEngine;
using System.Collections;
public class xroll : MonoBehaviour
{
public float speed = 0.5f;
void Update()
{
Vector2 offset = new Vector2(Time.time * speed,0);
GetComponent<Renderer>().material.mainTextureOffset = offset;
}
}
but after some time it doesnt move smoothly like the fps are dropping . (only on devices,tested on iphone 6s) on the pc it runs fine.Does anybody know the problem?Is there another way to do it?
Comment
Sounds like a garabge collection issue on mobile devices. $$anonymous$$aybe try getting the component only once at start and reuse it in update?
$$anonymous$$aterial mat;
void Start()
{
mat = GetComponent<Renderer>();
}
void Update()
{
... your stuff
}
And if that doesnt work out, try to use the unity profiler and look at the stats. What does the memory part look like? Do you have the same problem on android?
Tested on Android and its fine.Seems like iOS problem.