• Load资源绕过异步,必须load结束才进行下面操作


    public void Init()
        {
             FDJson();
        }
        
        
        void FDJson()
        {
            using(WWW _load = new WWW("file://"+ FileFunc.GetStreamPath("FontPreferenceC.json")))
            {
                while(!_load.isDone)
                {
                    
                }
                ftData = JsonReader.Deserialize<FTData>(_load.text);
                
                if (FontData.shareData.FD == null)
                {
                    print("hahaha:  null");
                }
                else
                {
                    print("not null :  "+ FontData.shareData.FD.reinforceGroup.mainPage.BarTitle );
                }
                print("111111");
            }
        }

    如果异步则用StartCortine

    public void Init()
        {
             StartCortine(FDJson());
        }
        
        
        IEnumerator FDJson()
        {
            using(WWW _load = new WWW("file://"+ FileFunc.GetStreamPath("FontPreferenceC.json")))
            {
                yied return _load;
                ftData = JsonReader.Deserialize<FTData>(_load.text);
                
                if (FontData.shareData.FD == null)
                {
                    print("hahaha:  null");
                }
                else
                {
                    print("not null :  "+ FontData.shareData.FD.reinforceGroup.mainPage.BarTitle );
                }
                print("111111");
            }
        }

    异步只是协程,不是多线程

  • 相关阅读:
    [BZOJ3172]单词
    [BZOJ2434]阿狸的打字机
    [BZOJ1195]最短母串
    [codeforces743E]Vladik and cards
    [BZOJ2553]禁忌
    [BZOJ1009]GT考试
    [BZOJ3507]通配符匹配
    [BZOJ4027]兔子与樱花
    test20190308
    Luogu P2742 模板-二维凸包
  • 原文地址:https://www.cnblogs.com/pengyingh/p/3014520.html
Copyright © 2020-2023  润新知