Front & Back Camera Switching
Hey guys,
I used the following script to create "tap to switch texture", but now I can't tap to focus neither double-tap to switch camera .. any solution, please?
// @input Component.Image image
// @input Asset.Texture[] textures
// Our starting texture index
var currentItemIndex = 0;
// Assign the initial texture to our image
script.image.mainPass.baseTex = script.textures[currentItemIndex]
// Define what happens when you tap.
function changeTexture () {
// Increment the current item index
currentItemIndex += 1;
// We need the current item index to wrap around
// once it's higher than the number of items we have.
currentItemIndex = currentItemIndex % script.textures.length;
// Change the image's texture
script.image.mainPass.baseTex = script.textures[currentItemIndex];
}
// Bind the function to the touch event.
var touchEvent = script.createEvent("TapEvent");
touchEvent.bind(changeTexture);
Hi,
You can use something like this to do it:
https://lensstudio.snapchat.com/guides/scripting/touch-input/
Then short the script, add it into it's own image, for example:
After that, it could work perfectly
Hello,
Thanks for your reply
But to be honest I didn't really understand, as I tried the link you posted.
Thank you
Hey, Thank you for replying back.
I will try to get a example project up for you.
Hey a_ij,
Are you by any chance using touchBlocking in any of the scripts? This will disable the ability to use tap gestures like focusing and double-tapping to switch cameras. You can set touchBlocking to false, or remove it entirely, and even set exceptions for the touchBlocking so certain inputs still work!
Check this out for more information - https://lensstudio.snapchat.com/api/classes/TouchDataProvider/
Hey Ben,
I assigned a mesh visual object that when I tap on, the texture will change. Moreover, I resized the mesh visual object to be full screen so I can tap anywhere on the screen and the texture will change.
No any touchBlocking in my script.
Thank you
Hello again.
I apologize for using such long time. I tried to do it from scratch but the script didn't really want to cooperate with me, so i had to use the soundboard template and modify it.
https://drive.google.com/open?id=1Myi5LluSyNUiQl75jKT3aJbIHorEanbD
I forgot to clean up the project.
Let us know if you need anything else.
Thanks n
And Ben, I tried your way on youtube and it seems that it works without troubles.
Thanks everyone !
Glad to hear you got it solved.
May i know which youtube video solved your problem so i can advice people to check it out if they got the same problem
That one !
https://www.youtube.com/watch?v=5-nBZzmEbNk
Awesome, Thank you for providing it.
Have fun creating! :D
Thank you !