Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Fix "Array index is out of range" problem

$
0
0
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[i]); } void ChangeImage() { if(i<=197) { if(currentImageTime >= 300f) { OnGUI (); currentImageTime = 0f; } else{} } }

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>