Story with Textures

Hey everyone,
I’m am trying to tell a story in between levels n my game. I want to tell the story with multiple pictures. First picture is displayed for a few seconds and then the next.

I know how to display the first picture but not sure how to make it wait a few seconds and then display the next. My work around at the moment is multiple scenes… Which I don’t think is right.

Can anyone give some guides or just explain the logic for this.
Thanks again guys!!

One way would be to have an array of Texture2d that contain all the slides you want.

Declare your delay and in the Update function count until the delay is expired then increment the index count. In the GUI use whatever method you are using to the draw the texture but reference it with textureArray[index].

public Texture2D[] slides;
float delay = 2;
float timePassed = 0;
int index = 0;

void Update()
{
	if(index < slides.Length)
	{
		if(timePassed < delay)
		{
			timePassed += Time.deltaTime;
		}
		else
		{
			timePassed = 0;
			index++;
		}
	}
	//we've reached the end of the slides
	else
	{
		//do something at the end
	}
}

void OnGUI()
{
	GUI.DrawTexture(rect, slides[index]);
}

Here’s my method using a coroutine :slight_smile:

using UnityEngine;
using System.Collections;

public class ImageTransition : MonoBehaviour
{
	public Texture2D[] textures;
	public int transitionTime = 2;
	
	private int currentTexture = 0;
	
	void Start()
	{
		StartCoroutine(TransitionTimer());
	}
	
	void OnGUI()
	{
		GUI.DrawTexture(new Rect(0,0,Screen.width, Screen.height), textures[currentTexture]);
	}
	
	private IEnumerator TransitionTimer()
	{
		while (currentTexture < textures.Length -1) 
		{
			yield return new WaitForSeconds(transitionTime);
			currentTexture++;
		}
	}
}