- Home /
Set a RawImage UVRect values via script?
Trying to do an animated sprite sheet using a RawImage. Can't use an Animator/Animation (at least I don't think so) because I want to make a countdown timer that's accurate to the millisecond. So far I'm stuck on updating the RawImage's UVRect values. I need to update the X and Y values to show the correct slice of my sprite-sheet. Still pretty new to Unity, the new gui and C# so kinda stuck on how to apply the new values. Any help would be great, thanks.
Answer by g8minhquan · Dec 15, 2014 at 02:04 AM
You can use
yourRawImage.uvRect = new Rect(newX, newY, newW, newH);
Thanks. Seems confusing that the rect has Set() which does nothing. I suppose the same Rect type is used in other places where modifying it does have an affect. This does nothing:
yourRawImage.uvRect.Set(0, 0, 1, 0.5f);
Your answer
Follow this Question
Related Questions
GUI DrawTexture is sliding across the screen? 0 Answers
Place UI element on pointer up position. 1 Answer
Unlocking & "Equipping" Colors onto Sprites with c# 2 Answers
2D animation can not be found. 0 Answers