using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class Layer3 : MonoBehaviour { public Button btn;
public Image line;
public Image pic;
private int index = 0;
// Start is called before the first frame update
void Start()
{
btn.onClick.AddListener(OnClick);
}
// Update is called once per frame
void Update()
{
}
private void OnClick()
{
index++;
if (index%2==1)
{
StartCoroutine("StartDisplay");
}
else
{
StopCoroutine("StartDisplay");
StopCoroutine("StartPlayCamera");
line.fillAmount = 0.0f;
pic.gameObject.SetActive(false);
}
}
private IEnumerator StartDisplay()
{
while (line.fillAmount<1.0f)
{
line.fillAmount += 0.1f;
yield return new WaitForSeconds(0.03f);
}
StartCoroutine("StartPlayCamera");
}
private IEnumerator StartPlayCamera()
{
yield return new WaitForSeconds(0.2f);
pic.gameObject.SetActive(true);
}
private void OnDisable()
{
if (pic.gameObject.activeSelf)
{
line.fillAmount = 0.0f;
pic.gameObject.SetActive(false);
index++;
}
}
}
|