因此,我将对象放入场景中,然后通过检查器(对象名称旁边的复选标记框)将其设置为“不可见”(如果您愿意,请停用),等待 8 秒后它不可见。我正在使用 Unity 2d 和 C#。
我让游戏开始暂停三秒钟,然后在有效之后播放。第一个脚本就是那个。该项目应该在 8 秒后重新出现,所以在游戏恢复后,这不起作用。
//delay before level starts script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class countDown : MonoBehaviour
{
public GameObject CountDown;
private void Start()
{
StartCoroutine("StartDelay");
}
void Update()
{
}
IEnumerator StartDelay()
{
Time.timeScale = 0;
float pauseTime = Time.realtimeSinceStartup + 3f;
while (Time.realtimeSinceStartup < pauseTime)
yield return 0;
CountDown.gameObject.SetActive(false);
Time.timeScale = 1;
}
{
//script for the flower to appear
IEnumerator Start()
{
print(Time.time);
yield return new WaitForSeconds(8);
print(Time.time);
flowerInScene.gameObject.SetActive(true);
}
[SerializeField] Transform flowerInScene;
}