so I made a small bit of code to play a 3 sec video, after it plays quite well this error pops up and pauses the game: “IndexOutOfRangeException: Array index is out of range”.
How is this to be fixed? I tried to add some if() to the code, but some are just useless.
public Texture2D[] images;
private int i=0;
public float currentImageTime = 0f;
void Update ()
{
currentImageTime += Time.deltaTime;
ChangeImage();
}
void OnGUI()
{
i++;
GUI.DrawTexture(new Rect(100,100,500,500), images*); *
-
}*
-
void ChangeImage()*
-
{*
-
if(i<=197)*
-
{*
-
if(currentImageTime >= 300f)*
-
{ *
-
OnGUI ();*
-
currentImageTime = 0f;*
-
}*
-
else{}*
-
}*
-
}*