1.核心代码示例
文章来源地址https://www.toymoban.com/news/detail-770155.html
2.代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AddRandomChilden : MonoBehaviour
{
// Debug.Log("开始进入update");
float i = 0;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (i >1)
{
Debug.Log("开始创建sphere");;
int xRange=Random.Range(-10,10);
int zRange=Random.Range(-10,10);
GameObject objB = Instantiate(GameObject.CreatePrimitive(PrimitiveType.Sphere), transform);
objB.transform.position = new Vector3(xRange, 0,zRange);
objB.transform.localScale = new Vector3(0.3f, 0.3f,0.3f);
i = 0;
}
i += Time.deltaTime ;
Debug.Log(i);
}
}
文章来源:https://www.toymoban.com/news/detail-770155.html
到了这里,关于unity计时,1秒执行一次的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!