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

Unity2021 能对async做补丁, 但不能使用await #386

Open
alan9988 opened this issue Nov 25, 2022 · 4 comments
Open

Unity2021 能对async做补丁, 但不能使用await #386

alan9988 opened this issue Nov 25, 2022 · 4 comments

Comments

@alan9988
Copy link

alan9988 commented Nov 25, 2022

[IFix.Patch]
public async void OnBtnStart()
{
    Debug.Log("---111---");
    m_VersionText.text = 1.ToString();
    if (m_Started)
    {
        return;
    }
    Debug.Log("---2222---");
    await Task.Delay(3000);
    m_VersionText.text = 2.ToString();
    Debug.Log("---333---");

Output:

11-25 17:25:33.413 2475 2491 I Unity : ---111---

11-25 17:25:33.419 2475 2491 I Unity : ---2222---

后面的代码没运行

@alan9988
Copy link
Author


    [IFix.Patch]
    public async void OnBtnStart()
    {
        Debug.Log("-----1---------");
        if (m_Started)
        {
            return;
        }
        Debug.Log("-----2---------");
        m_Started = true;
        await UniTask.WaitUntil(()=>Game.AB.IsReady);
        Debug.Log("-----3---------");
        await Game.Scene.LoadScene(AssetPathHelper.LocateScene("MapScene"));
        Debug.Log("-----4---------");
    }

Output:

11-29 15:17:01.278 6978 6997 I Unity : -----3---------

11-29 15:17:01.309 6978 6997 I Unity : -----1---------

11-29 15:17:01.310 6978 6997 I Unity : -----2---------

运行次序不正常

@haiyaojing
Copy link

+1

1 similar comment
@lishengru
Copy link

+1

@lishengru
Copy link

+10086

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants