Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

协程里LoadSceneAsync加载场景后,后面的代码执行不到 #369

Open
unitykkk opened this issue Sep 9, 2024 · 3 comments
Open
Labels
bug Something isn't working

Comments

@unitykkk
Copy link

unitykkk commented Sep 9, 2024

Yooasset版本:2.2.4-preview。Unity2021.3.14f1,平台WebGL,windows都测试遇到以下问题:
void Start()
{
StartCoroutine(Run());
}

IEnumerator Run()
{
    // 初始化资源系统
    YooAssets.Initialize();

    // 创建默认的资源包
    var package = YooAssets.CreatePackage("DefaultPackage");
    
    // 设置该资源包为默认的资源包,可以使用YooAssets相关加载接口加载该资源包内容。
    YooAssets.SetDefaultPackage(package);

    yield return InitPackage(package);

    yield return RequestPackageVersion();

    yield return UpdatePackageManifest();

    //5.资源包下载
    Debug.LogError("5. 资源包下载");
    yield return Download();

    //6.加载场景
    var handle = package.LoadSceneAsync("Main");//不用加后缀
    yield return handle;
    Debug.LogError($"Scene name is {handle.SceneName}");

    //7.加载预制体
    AssetHandle handle0 = package.LoadAssetAsync<GameObject>("Block");//不用加后缀
    yield return handle0;

    GameObject go = handle0.InstantiateSync();
    Debug.LogError($"Prefab name is {go.name}");
}
上面的代码,在执行LoadSceneAsync加载场景后,yield return handle之后的代码Debug.LogError($"Scene name is {handle.SceneName}");执行不到,会阻塞。
@gmhevinci
Copy link
Collaborator

是否有错误日志?

@Zik-One
Copy link

Zik-One commented Oct 11, 2024

我和你存在同一个问题、我这边的原因是打包资源过程中,没有将运行场景用到的脚本代码带入(主包)或者(热更新资源包),造成加载场景之后、场景初始化时系统卡死。你可以看看你的项目打包资源,是否包含了运行时候的资源。

@gmhevinci gmhevinci added the bug Something isn't working label Oct 15, 2024
@gmhevinci
Copy link
Collaborator

标记为bug,请不要关闭该issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants