I have a number of animated banners that have to animate indefinitely in one direction.
I have run into a number of problems, including animating an Image’s material effects all materials in the canvas, if Images share a material instance they all fight over the UVs etc. etc… So I have made a script to make a material at runtime and apply it, then only effect that material. This works in Editor but not on Mobile.
[RequireComponent(typeof(Image))]
public class UV_Scroller : MonoBehaviour
{
public Vector2 uvAnimationRate = new Vector2( 1.0f, 0.0f );
private Vector2 uvOffset = Vector2.zero;
private Image _image;
private Material _mat;
private void Start()
{
_image = gameObject.GetComponent<Image>();
_mat = new Material(Shader.Find("Unlit/Transparent"));
_image.material = _mat;
}
void Update()
{
uvOffset += ( uvAnimationRate * Time.deltaTime );
_mat.SetTextureOffset(textureName, uvOffset);
}
}
I have also ensured the shader is listed in the graphics settings as detailed here: Unity Forum post
Any help would be most appreciated