写一个简单的测试脚本如下:
public class testOrder : MonoBehaviour {
void Start()
{
Debug.Log(gameObject.name+" Start!");
}
void Awake()
{
Debug.Log(gameObject.name+" Awake!");
}
void OnEnable()
{
Debug.Log(gameObject.name+" OnEnable!");
}
void Update()
{
if (Time.frameCount == 10)
{
Debug.Log(gameObject.name+" Update at 10!");
}
}
}
建立三个GameObject,层级结构如下:
给3个GameObject全部挂上此脚本,运行后得到的顺序如下: