Slider callback
Hello,
I'm trying to get a callback from a slider to work.
I'm following the example but I get an error. (https://lensstudio.snapchat.com/guides/scripting/helper-scripts/user-interface/)
20:37:45 [Scenarium] TypeError: undefined not callable (property 'addCallback' of [object Object])
at [anon] (Script.js:10) preventsyield
Here is my code
// -----JS CODE-----
//@input Component.ScriptComponent colorPickerScript
print("hello")
function changeColor(newColor){
//script.targetVisual.mainPass.baseColor = newColor;
print(newColor)
}
script.colorPickerScript.api.addCallback("onColorChanged", changeColor);
thank you
I was able to make it work.
I had to create a new object and attach my script to it.
The way I found out was by playing around with the High Score template which uses a Component.ScriptComponent component as well.
Here is a screenshot in case someone runs into this issue as well.
Again I believe the documentation could do a better job at explaining these details.
I had this same issue, but it was bugging out because my script was above the slider in the scene graph. Moving it below the slider fixed it