- Home /
Question by
Mr. Crumbles · Jan 22, 2014 at 08:40 PM ·
spritespriterenderer
Is there a way to change a Sprite's Rect at runtime?
I'm creating a HUD system using the built-in Sprite class and I need a way to dynamically change a Sprite's rectangle in script. (for effects such as health bars and other stuff where different amounts of the sprite texture are shown depending on the state of my object). I'd rather not use scaling because I want the texture to be clipped, not squashed.
Setting sprite.rect does not work as the value is readonly. Is there any way to achieve what I need? Using GUI textures is not an option because this HUD system needs to exist in 3d space.
Comment