视频笔记-Unity脚本-Messages-P116~P119

原视频链接

Messages of MonoBehaviour

在这里插入图片描述

物理阶段

  • MonoBehaviour.FixedUpdate()
    每隔固定时间(时间可以修改)执行一次。适合对物体做物理操作,不会受到渲染影响。

输入事件

  • MonoBehaviour.OnMouseDown()
    OnMouseDown is called when the user has pressed the mouse button while over the Collider.
    所以如果没有激活或者没有 collider 组件的话点击无效。

游戏逻辑阶段

  • MonoBehaviour.Update()
    渲染帧执行,执行间隔不固定。适合处理游戏逻辑。
  • MonoBehaviour.LateUpdate()
    Update函数被调用后执行,适用于跟随逻辑。
    例如对于相机跟随,物体移动写在Update,相机跟随写在LateUpdate

场景渲染

  • MonoBehaviour.OnBecameVisible()
    OnBecameVisible is called when the renderer became visible by any camera.(就那一帧)
  • MonoBehaviour.OnBecameInvisible()
    OnBecameInvisible is called when the renderer is no longer visible by any camera.(就那一帧)

结束阶段

  • MonoBehaviour.OnDisable()
    This function is called when the behaviour becomes disabled.
  • MonoBehaviour.OnDestroy()
    Destroying the attached Behaviour will result in the game or Scene receiving OnDestroy.
  • MonoBehaviour.OnApplicationQuit()
    Sent to all game objects before the application quits.
    In the editor this is called when the user stops playmode.

调试

控制台调试

Debug.Log();
MonoBehaviour.print();	// 事实上 print 调用了 Debug.Log

写公开变量,直接查看

public float time;
void Update()
{
	time = Time.time;	// 在编辑器中实时查看 Time.time
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值