So I want to add a few images (comics) to my level just before it starts. Got something but not being a left brain person doesn’t help much. Here’s the script that gives me an array index out of range (also, it does the “we’re done here” before anything else instead of right after the last slide")
var imageArray : Texture[];
var currentImage : int;
var imageRect : Rect;
var buttonRect : Rect;
var customSkin : GUISkin;
var btnHeight = 10;
var btnWidth = 100;
function Start()
{
if(currentImage > 1)
currentImage = 0;
imageRect = Rect(0, 0, Screen.width, Screen.height);
buttonRect = Rect(0, 0, Screen.width/4-btnWidth, Screen.height/10-btnHeight) ;
if(currentImage < 2)
Debug.Log("We're done here");
}
function OnGUI()
{
GUI.skin = customSkin;
GUI.Label(imageRect, imageArray[currentImage]);
if(GUI.Button(buttonRect, "Next"))
currentImage++;
}
Any help is greatly appreciated!