TypeError when trying to set sprite alpha
Hello!
I'm currently trying to set the alpha for a sprite through a tap. But I get an error in my script.
This is my script:
// Properties:
//@input Component.SpriteVisual ugsprite
// Sets the alpha of the sprite visual to 0.5
script.ugsprite.getMaterial(0).getPass(0).baseColor = new vec4(1, 1, 1, 0.5);
I have named my sprite "ugsprite" in under the Objects section, but the error I get when clicking is this:
TypeError: cannot read property 'getMaterial' of undefined
at [anon] (Script:4) preventsyield
Could someone please help me find the cause to this? :)
Solved it
Hi Roger,
Glad it worked out!
Please reach out to us if you have any other questions!
Cheers,
Karolina