当前位置:网站首页>Unity3d:场景加载 GameObejct上脚本执行顺序
Unity3d:场景加载 GameObejct上脚本执行顺序
2022-07-23 05:45:00 【四夕立羽】
场景1脚本
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;
}
}
场景2某个物体上挂载
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");
}
}
场景2截图
执行后输出

可以看到,加载LoadScene2完成,会执行LoadScene2里所有的GameObject的Awake,OnEnable,Start,和update会执行一次,再真正加载完场景
所以,在优化场景加载时,代码层面关注新场景里固有GameObject上脚本里执行逻辑复杂度
边栏推荐
- Unity3D高清渲染管线无法在模型上播放视频
- 冒泡排序,快速排序
- URL查询参数编码问题(golang)
- C语言数据库:详细的说明用学生管理系统了解数据库的操作,简单易懂。
- 表格个人简历
- 0回溯/动态规划中等 LeetCode526. 优美的排列
- Blog Building III: comment system selection
- Embedded from entry to mastery (buried) - sharing of ultra detailed knowledge points 3
- Implementation of heap and heap sorting
- Unity鼠标控制摄像机拖拽、旋转、缩放(模拟编辑器摄像机功能)
猜你喜欢

Enter the triangle side length and calculate the area

WebSocket 协议讲解

Blog building 4: how to add your blog to Baidu and Google

Three versions and optimization of quick sorting by interval -- friends may not know it

Question bank of basic principles of steel structure

linkerd服务网格调研笔记

LVS负载均衡调度原理及配置方法

快速排序的按区间的三个版本及优化--友友们不一定了解

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

C language small project - student achievement management system
随机推荐
C#(CSharp) 微信公众号开发一 基本配置
Knowledge structure of advanced algebra
Unity3d:特效对象池,超时删除池内GameObject,GC权值
[learning summary]
hot 100 动态规划
LVS负载均衡调度原理及配置方法
博客搭建一:框架选择
刷题笔记:二叉树的中序遍历(三种解法-递归,迭代,Morris)
剑*offer04 重建二叉树
Using one-way linked list to realize queue
剑指offer 青蛙跳楼梯
switch实现表达式计算
博客搭建三:评论系统选择
LeetCode题解汇总
3.2daydayup举一反三:三天打鱼两天晒网式学习
TeX or LaTeX or MikTeX or TeX Live or CTeX
牛客面试必考真题【算法篇】高频Top200 题目汇总
[AUTOSAR com 2. Advanced introduction to communication protocol stack]
常见的排序—交换排序
Awk programming language