Unity笔记—3(c#脚本在Unity的执行流程)
前言
自学笔记,没有历史知识铺垫(省略百度部分),系列性的记录核心的实用笔记,本章主要记录c#脚本在Unity的执行流程Unity版本(Unity Hub管理):2020.1.14f1c1
IDE工具(Unity Hub管理):Visual Studio 2019
一、c#脚本基础执行流程
Unity官方提供的脚本执行顺序(早起版本顺序可能与此图不一致,可以去官网手册查看不同版本准确顺序)using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
void Awake() {
Debug.Log("===1=== start Awake 载入实例化时执行,即便没有激活也会执行");
}
private void OnEnable()
{
Debug.Log("===2=== start OnEnable 勾选激活时执行");
}
// Start is called before the first frame update
void Start()
{
Debug.Log("===3=== start Start 使用时执行");
}
private void FixedUpdate()
{
Debug.Log("===4=== start FixedUpdate 固定间隔刷新");
}
// Update is called once per frame
void Update()
{
Debug.Log("===5=== start Update 受帧率渲染等影响间隔");
}
private void LateUpdate()
{
Debug.Log("===6=== start LateUpdate 受帧率渲染等影响间隔");
}
private void OnDisable()
{
Debug.Log(" ===7=== start OnDisable ");
}
private void OnDestroy()
{
Debug.Log(" ===8=== start OnDestroy 销毁实例化时执行,即便没有激活也会执行");
}
}