#How to use script in Lens Studio 5.3 of Tap to Change Event in Cause they've removed simple script.

3 messages · Page 1 of 1 (latest)

modest yacht
#

also they're not working for me in any way I've tried so many ways if you;ve readymade project after 2024 Jan and File Extension type is LSProje do share zip with me or Screen recording of project I just want to see setting of new version my older fils not working after update and i have to submit to client in 10 days.

I'll appreciate all the help and support.

drifting ridge
#

Hi, tap to change for? Scene, object, mesh, effect vfx, etc?

#

Only For camera

// -----CRX CODE-----
// @input SceneObject[] obj

var count = 0;

// Display the first object
script.obj[0].enabled = true;

// Disable all other objects
for (var i = 1; i < script.obj.length; i++) {
    script.obj[i].enabled = false;
}

// Function called when the screen is tapped
function onTapped(eventData) {
    count++;

    // Loop through all objects
    for (var i = 0; i < script.obj.length; i++) {
        // If it's the current object, display it
        if (count == i) {
            script.obj[i].enabled = true;
        } else {
            // Otherwise, hide it
            script.obj[i].enabled = false;
        }
    }

    // If all objects have been displayed, restart from the beginning
    if (count == script.obj.length) {
        count = 0;
        script.obj[0].enabled = true;
    }
}

// Bind the function to the TapEvent
var event = script.createEvent("TapEvent");
event.bind(onTapped);