"No Component at index" - Bug? Please Help!
Hello people,
I am fighting with this basic snippet of code: My Logger outputs a constant error of
"No Component at index:0"
might this be a bug? I cannot see what I am doing wrong.
Best eL
// -----JS CODE-----
global.touchSystem.touchBlocking = true;
var fishAnimation = script.getSceneObject().getFirstComponent("Component.SpriteVisual");
script.createEvent("TapEvent").bind(function()
{
fishAnimation.mainPass.baseTex.control.play(1, 0);
});
Can you share a screenshot of the sceneobject this script is on?
Hey Brandon,
interesting that the same setup on my Mac in an older Version of LensStudio works as it should.
Right now I am working on WIN10 with NVIDIA Graphics.
here´s the screenshot.
Thank you for looking into this.
Ah sort of what I guessed...
Newer lens studio versions use Images now instead of Sprite Visuals.
So you need to change "Component.SpriteVisual" to "Component.Image".
Sprites can still be accessed in the objects list under legacy, but in your picture you are using an Image component.
Hope this fixes it!
WOW, thank you Brandon.
how would I know about such a change in syntax? just for future reference...
cheers eL
you would replace
var fishAnimation = script.getSceneObject().getFirstComponent("Component.SpriteVisual");with
var fishAnimation = script.getSceneObject().getFirstComponent("Component.Image");
That should fix it!
You can check the update log to see some changes https://lensstudio.snapchat.com/download/
others you may just have to check the documentation really and double check component names in the inspector.
You can check the update log to see some changes https://lensstudio.snapchat.com/download/
others you may just have to check the documentation really and double check component names in the inspector.