Image Cycle
I'm trying to make a script so when you tap on the screen, it changes the first image alpha to 0, and the second one to 1. Then on the second tap, change second image alpha to 0, and the third to 1, and so on. How would I do that? I can't figure it out through the articles as I have done thorough searching and haven't seen anything that would be helpful.
-
Hello, tyyylerxxx you could use the Fullscreen Template and modify it a bit (no scripting needed) !
It's similar to what Kelsey wanted to do, but as i understand with images and not face masks.
Also check this old post :
Best,
Nick
-
Hey Tyler,
If you are just trying to enable/disable a series of images so you cannot see them, take a look at the Fullscreen Template. All you would need to do is plug your images into each Template Slate! That script is built for much more than just showing and hiding images on tap, you can do a lot of things like play/stop music and animations as well!
If you specifically need to change alpha to 0, you would need to change the baseColor property of your image. That property is represented in a vec4 format (R,G,B,A). That code would look something like this:
// @input Component.Image image
script.image.mainPass.baseColor = new vec4(1, 1, 1, 0);Let me know if you have any questions!
Ben
-
hi tyyylerxxx
there is many ways to do that
to edit an alpha of image you need to code it and also need a function changes between the two images ...
all you need is a simple way
check the behavior scriptsimply use a clicked images by adding the touch component
1 : click on the first image shown ( the last image added )
2 : in the inspector panel click add component and select the Touch Component
3 : in the Mash Visual select the same image you clicked before
( repeat for the second image )now all you need is to create a project and use the behavior script
1 : create an empty new project . click on it and drag the behavior script to the inspector panel
2 : select Touch Event in the Trigger
3 : select the clicked image in the Touch Target
4 : in the Response Type select SET ENABLED
5 : you will notice a new Target select in it one of the two images
6 : in Action select Disableduplicate the behavior script and repeat the same steps but change in
5 : the target must be the second image
6 : in Action must select enablednow so far all you got is when you click on the one image one disabled and other enabled
.you can repeat all of this for the second image
when the second image clicked the second one disabled and the first one enabled
if you have any questions let us knowhave fun.
Please sign in to leave a comment.
Have a comment?