Image Sequence Play Once Stop
I have a Javascript that loads images from the resource folder, then plays the image sequence back. However it loops the playback infinitely. I'd like the sequence to play once then stop on the last frame of the sequence. Here is the image sequence loader/repeater script.
private var quarterCircleValues = [];
var texture : Texture;
renderer.material.mainTexture = texture;
var changeInterval = 0.33;
function Awake() {
quarterCircleValues =开发者_C百科 image_Loader.LoadSequence("adowner", 0150);
}
function Update() {
if( quarterCircleValues.length == 0) //nothing if no textures
return;
//we want this texture index now
var index :int = Time.time / changeInterval;
//take a module so that animation repeats
index = index % quarterCircleValues.length;
//assign it
renderer.material.mainTexture = quarterCircleValues[index];
}
I've tried removing the 'repeat module' but that results in the sequence playing once per session then leaves a blank display. How can I program it to play once then stop?
Hmm, I'd go for
if (index < quarterCircleValues.length) {
renderer.material.mainTexture = quarterCircleValues[index];
}
instead of
//take a module so that animation repeats
index = index % quarterCircleValues.length;
//assign it
renderer.material.mainTexture = quarterCircleValues[index];
or even try to stop the interval that must be calling the Update-function if the index is too large (that would be better). But I don't know what you're using, so I can't test it.
精彩评论