How to use Clone() on Animatedtexture
AnsweredI saw that there is a clone() function on Animated Texture Provider. https://lensstudio.snapchat.com/api/classes/AnimatedTextureFileProvider/
So I tried it, but got an error.
How to use this function properly?
function init(){
var myLength = script.objBird.length;
for(i=0;i<myLength;i++){
birdTex[i] = script.texBirdAnim.control.clone()
script.objBird[i].getComponent("Component.Image").mainPass.baseTex = birdTex[i]
script.objBird[i].getComponent("Component.Image").mainPass.baseTex.control.play(1,0)
}
}
init();
Can anyone can help me with this? Thanks!
What error did you get?
Hey,
Pls send the error what you get that we can help you!
Best,
justin.crx
Hi, I tried it again today with simplified version of the script
Please let me know how to use this properly!
PS. The imageA has animated texture on it
Thanks!
Hey,
Try this: https://lensstudio.snapchat.com/api/classes/AnimatedTextureFileProvider/
Yeah, I saw that. Before I post it in here, but as you can see it gives me error.. can you give me example of how to use this in script? Thank you!
Hellooo??? its been 7 days but no one answer my simple question
Hi, Jhonnel Pica
The clone method actually clones Texture Provider and not a texture itself.
You have to set cloned texture provider to be a control of another texture. This should work :
Note that I assume you are using default material on the Images.
Please let me know if this works for you! I can attach example project if needed
Best
Olha
Thanks Olha , the code works but not what I expected because I thought that it will clone the texture itself so I can offset other animation without duplicating the same texture animation.
I see! It's not that straightforward but still can be used for your case. You just need a texture reference to set provider to, that's why i was using default material.
You can also use proxy texture asset for this
Olha how did you use proxy texture? theres no setting when I click on it
Hi, Jhonnel Pica
It's just an empty texture before anything is assigned to it. You can use it to create your copy. For example:
And now you can use that proxy texture resource in Materials right away
My setup :
Best
Olha
Wow!! Thank you so much @olha .. This is a nice trick!