Resize an image via script

Hi! Could you please help me how to resize an image via script?

I would like to make a bar longer as I press the spacebar. For that purpose I’ve created an empty, a camera and a camera-attached UI canvas element. I added raw image component to the empty. And placed an image into it (sprite, texture, doesn’t matter). How do I transform its width via script?

Thanks!

any ideas ? :smiley: