Hi,
I have a sprite sheet which I have attached to a Raw Image component in Unity. The Raw Image component has a UV Rect property with X/Y/W/H parameters. What I want do do is to animate the sprite sheet by changing those values over time through a script, which I have attached to the same Game Object.
I do this in my script:
RawImage image = gameObject.GetComponent();
Rect uvRect = image.uvRect;
uvRect.size = new Vector2(value, value);
uvRect.position = new Vector2(value, value);
The values are correctly reflected in the code but when I look at the inspector the values are unchanged and the image does not animate. If I change the values manually in the inspector during runtime, it works correctly. Any suggestions?
Kind Regards,
Robin