This code is meant to animate the UV on a RawImage component so that it animates. It was working in a 2019 version of Unity. However, updating to 2020.1.15f1 causes the below code to do nothing (without error). From the Inspector view, it doesn’t seem like it’s changing the material of the RawImage.material. Is this a bug or does the RawImage component have different functionality now?
using UnityEngine;
public class AnimatedImageUV : MonoBehaviour
{
public Vector2 Scroll = Vector2.zero;
private Vector2 _offset = Vector2.zero;
private Material _mat = null;
private UnityEngine.UI.RawImage _image = null;
private void Start()
{
_image = GetComponent<UnityEngine.UI.RawImage>();
_mat = UnityEngine.Object.Instantiate(_image.material);
}
void Update()
{
float time;
time = Time.unscaledTime;
_offset.x = time * Scroll.x;
_offset.y = time * Scroll.y;
_mat.SetTextureOffset("_MainTex", _offset);
_image.material = _mat;
}
}