当前位置:网站首页>Unity3d: script execution sequence on scene loading gameobejct
Unity3d: script execution sequence on scene loading gameobejct
2022-07-23 12:52:00 【Sixi Liyu】
scene 1 Script
public class LoadScene1 : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
StartCoroutine(StartScene());
}
IEnumerator StartScene()
{
AsyncOperation aync = SceneManager.LoadSceneAsync("LoadScene2", LoadSceneMode.Additive);
while (aync.isDone == false)
{
Debug.Log(aync.progress);
yield return null;
}
Debug.Log("LoadOK");
yield return null;
}
}
scene 2 Mount on an object
public class LoadScene2 : MonoBehaviour
{
private void Awake()
{
Debug.Log("Awake");
}
// Start is called before the first frame update
void Start()
{
Debug.Log("Start");
}
private void OnEnable()
{
Debug.Log("OnEnable");
}
private void Update()
{
Debug.Log("Update");
}
}
scene 2 Screenshot 
Output after execution 

You can see , load LoadScene2 complete , Will execute LoadScene2 All in GameObject Of Awake,OnEnable,Start, and update Will execute once , After loading the scene
therefore , When optimizing scene loading , The code level focuses on the inherent in the new scene GameObject The complexity of executing logic in the script
边栏推荐
猜你喜欢

Learning diary - (routing and switching technology) layer 3 switch

unity3d:Assetbundle模拟加载,同步加载,异步加载,依赖包加载,自动标签,AB浏览器,增量打包

HCIP---MGRE综合实验

DHCP second experiment

C#:TopK:1万个数取前最大的100,堆排序

学习日记——(路由与交换技术)DHCP(动态主机配置协议)

@Requiredargsconstructor annotation use

Unity3D+moba+技能指示器(二)

学习日记——(路由与交换技术)网络地址转换 NAT技术

Unity3d:ugui, UI and special effect particle level, bakemesh above 2018.2, particles between two images and in Scrollview
随机推荐
Hcip --- mGRE comprehensive experiment
How far is the first kind of mistake from us
剖析Redis中的Sentinel模式
Homework of the fifth week
浅析UDP协议和TCP协议
DNS域名解析服务
整数乘以整数溢出了
C语言也能写植物大战僵尸
OSPF routing strategy and Traffic Capture
MySQL performance optimization, index optimization
Analysis of Internet Protocol (I)
htpasswd作用
How to solve too many if statements
浅做一下思科实验吧!
[memory understand the difference and function between ram flash and EEPROM memory]
Unity3d:场景加载 GameObejct上脚本执行顺序
post表单提交数据限制
Hcip - first experiment
How many seats do you need for 1000 people to eat in 2 hours?
OSPF和RIP的路由扩展配置