There might be a better way, but so far I’ve found that you can do this, and you can try other ways.
Goal: In UNITY, after clicking a button, three screens (or Raw images) appear in sequence: the first screen appears 1 second later, the second screen appears 3 seconds later and the first screen disappears, and the third screen appears 3 seconds later and the second screen disappears. The first step is to create a C# script in Assets, let’s name it delaydisplay3, double-click visual studio to open the edit.
The content of the program “delaydisplay3” is:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class delaydisplay3 : MonoBehaviour
{
// Define three public values to store the three UI background canvases that you want to control
public GameObject Canvas1;//定义画布1
public GameObject Canvas2;//定义画布2
public GameObject Canvas3;//定义画布3
public void Start1()
{
//Here are three delayed execution programs, the first second executes Delaynew1, the fourth second executes Delaynew2, the seventh second executes Delaynew3, so the interval is 1 second, 3 seconds, 3 seconds
Invoke("Delaynew1", 1f);
Invoke("Delaynew2", 4f);
Invoke("Delaynew3", 7f);
}
// Update is called once per frame
public void Delaynew1()
{
Canvas1.SetActive(true);//Implement activate canvas 1
}
public void Delaynew2()
{
Canvas1.SetActive(false);//实现关闭画布1
Canvas2.SetActive(true);//实现激活画布2这样实现图片切换
}
public void Delaynew3()
{
Canvas2.SetActive(false);//实现关闭画布2
Canvas3.SetActive(true);//实现打开画布3再次切换
}
}
Create and save. The value in front of MonoBehaviour should be the same as the filename in unity.
Then, Add the program to the BUTTON that needs to be bound. Click the BUTTON element in hierarchy, click Add Component at the bottom of inspector, and enter the delaydisplay3 script we just created. If the addition is successful, three blank interfaces should appear, as shown in the figure. In this case, you need to drag the three interface elements in the hierarchy, the first interface to Canvas1, the second interface, the third interface, and so on.

When the switch is complete, drag the button element onto the button execution page and find start1 () in Delaydisplay3

Now let’s run it again and see if it works
In this way, after clicking the button, the three interfaces are displayed successively, the first interface appears with a delay of 1 second, the second interface appears with a delay of 3 seconds and the first interface disappears, and the third interface appears with a delay of 3 seconds and the second interface disappears.
Another artical about unity development in our website:
another unity content: https://www.gongyesheji.org/?cat=860