Hi, i´ve been looking for a way to show a video in unity. Since i don`t have unity pro, i searched for an alternative to Movie/Render-Textures etc… I then found this script on the internet:
#pragma strict
var imageFolderName = "";
var MakeTexture = false;
var pictures = new Array();
var loop = false;
var counter = 0;
var Film = true;
var PictureRateInSeconds:float = 1;
private var nextPic:float = 0;
function Start () {
if(Film == true){
PictureRateInSeconds = 0.04166666666666666666;
}
var textures : Object[] = Resources.LoadAll(imageFolderName);
for(var i = 0; i < textures.Length; i++){
Debug.Log("found");
pictures.Add(textures*);*
}
}
function Update () {
if(Time.time > nextPic){
nextPic = Time.time + PictureRateInSeconds;
counter += 1;
if(MakeTexture){
renderer.material.mainTexture = pictures[counter];
}
}
if(counter >= pictures.length){
Debug.Log(“fertig”);
if(loop){
counter = 0;
}
}
}
Basically, what it does is let you display all images in a folder “x” in a short time on an object and so create a video effect. I tested the script and it worked really good, until it reached the end of the clip. The Game crashed and Unity showed me this error: “ArgumentOutOfRangeException: Index is less than 0 or more than or equal to the list count.”
I´m not very experienced with scripting, so i would be thankfull for any suggestions on where the mistake could be