Solution for cycling through multiple backgrounds
I want to create a lens that offers a series of images/textures for background segmentation (to offer options for videoconference backgrounds) and a functionality to select them, either through a picker or through cycling through a sequence via touch tap.
As a first step I have managed to switch to a new background via tap using behaviors, but I can´t seem to manage looping the sequence, resulting in a dead end once the last image is selected.
I am aware this should be feasible via a custom script, however I am sadly java illiterate, no matter how hard I try wrapping my head around this. Any advice on this?
Thank you so much in advance and happy easter, stay safe!
Would this be something your talking about imma put the example project right here just download it I'm going to also put the script down below. https://ucac6455b99a1cf493b0d6851b93.dl.dropboxusercontent.com/cd/0/get/A10a5QVNdJ8DGsbTD2TB4mU8XVIpcNN-83gKGcr0rxhJ96KzZXgOTaekEt_lV-_AYXcW0mqBOnWxdrMUtr0d21OQGG8ERMgo6-YV_d6CKmv6dprWuP5cCvXB9SEIMTKTPJQ/file?dl=1#
// @input SceneObject[] items
// Arrays are indexed from 0.
// Disable everything but the first (0th) item .
for (var i = 1; i < script.items.length; i++) {
script.items[i].enabled = false;
}
// We remember what item is currently visible.
// When we start it's the 0th item.
var currentItemIndex = 0;
// Define what happens when you tap.
function activateNextItem () {
// Disable the current item.
script.items[currentItemIndex].enabled = false;
// 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.items.length;
// Enable the new item.
script.items[currentItemIndex].enabled = true;
}
// Bind the function to the touch event.
var touchEvent = script.createEvent("TapEvent");
touchEvent.bind(activateNextItem)