Bind TapEvent to a specific input

Options
audun
audun Posts: 302 🔥🔥🔥

I'm trying to modify a script that is currently attached to my Orthographic camera.

The script runs whenever a tap is registered on the screen, but I want to modify it so that it only runs when someone taps one of the image inputs (muted or playing).

Here's the current script:

//@input Component.AudioComponent audio
//@input Component.Image muted
//@input Component.Image playing

var isPlaying = true;

script.muted.enabled = false;


function onToggle() {
     print("paused: " + script.audio.isPaused())
    isPlaying = !isPlaying;
    if (isPlaying) {
         print("playinhg" + isPlaying)
        script.audio.resume()
        script.playing.enabled = true;
        script.muted.enabled = false;
    } else {
        print("pausing")
        script.audio.pause();
        script.playing.enabled = false;
        script.muted.enabled = true;
    }
}

script.createEvent("TapEvent").bind(onToggle);

How can I do this?

Tagged:

Best Answer

  • audun
    audun Posts: 302 🔥🔥🔥
    #2 Answer ✓
    Options

    Solved it by adding an Interaction component to the Orthographic camera :smiley: