c#函数的编写与基本测试

函数的基本理解

1.FixedUpdate:每秒调用固定的帧数(物理运动平滑,跟电脑性能无关)
2.Update LateUpdate (前者先调用,后者后调用,在同一帧里调用的,调用次数是一致的,跟游戏环境有关系)
3.Enable执行的时候,Update才会执行
4.Disable执行的时候,Update会停止
5.OnTriggerXXX OnCollisingXXX :触发器
6.OnMouseXXX:跟鼠标操作有关
7.Debug.Log(“”)用于测试

Time

1.me.captureFramerate:可以设置帧的速率,可以进行屏幕截图,在当前帧可以完成
2.me.deltaTime:当前帧所占的时间,在1/60秒所占的值,变化相比于Time.smoothDeltaTime较大(也就是每一帧的时间间隔)
3.me.fixedDeltaTime:固定的帧数时间
4.meScale:游戏暂停或者游戏加速播放,默认是1.不会加速播放(通常设置的是时间的比例)
5.me.frameCount:帧数
6.me.realtimeSinceStartup:当游戏暂停或者后台运行的时候,时间会一直进行增加 (游戏从开始到结束所运行的时间)Time.time和Time.fixedTime两个都是游戏运行的时间,是差不多的,以游戏结束为单位的
7.me.timeSinceLevelLoad:从场景加载完成之后,开始计时,当调到下一个场景的时候,Time.time和Time.fixedTime都会继续增长,而Time.timeSinceLevelLoad会重新计时,因为它是以场景为单位的
继续增长。

注:

Time.time和Time.fixedTime,Time.timeSinceLevelLoad:都表示游戏运行,一共所占用的时间
Time.smoothDeltaTime:平滑的时间间隔,变化很小。

基本测试:
void Start(){
Debug.Log(“Time.deltaTime:”+Time.deltaTime);
Debug.Log(“Time.fixedDeltaTime:”+Time.fixedDeltaTime);
Debug.Log(“Time.fixedTime:”+Time.fixedTime);
Debug.Log(“Time.frameCount:”+Time.frameCount);
Debug.Log(“Time.realtimeSinceStartup:”+Time.realtimeSinceStartup);
Debug.Log(“Time.smoothDeltaTime:”+Time.smoothDeltaTime);
Debug.Log(“Time.time:”+Time.time);
Debug.Log(“Time.timeScale:”+Time.timeScale);
Debug.Log(“Time.timeSinceLevelLoad:”+Time.timeSinceLevelLoad);
Debug.Log(“Time.unscaledTime:”+Time.unscaledTime);
}
void Update(){
Debug.Log(“Time.deltaTime:”+Time.deltaTime);
Debug.Log(“Time.fixedDeltaTime:”+Time.fixedDeltaTime);
Debug.Log(“Time.fixedTime:”+Time.fixedTime);
Debug.Log(“Time.frameCount:”+Time.frameCount);
Debug.Log(“Time.realtimeSinceStartup:”+Time.realtimeSinceStartup);
Debug.Log(“Time.smoothDeltaTime:”+Time.smoothDeltaTime);
Debug.Log(“Time.time:”+Time.time);
Debug.Log(“Time.timeScale:”+Time.timeScale);
Debug.Log(“Time.timeSinceLevelLoad:”+Time.timeSinceLevelLoad);
Debug.Log(“Time.unscaledTime:”+Time.unscaledTime);
}
可以检测相应函数的运行状态。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值