tuyoogame / YooAsset

unity3d resources management system
https://www.yooasset.com/
Apache License 2.0
2.37k stars 466 forks source link

是否支持WebGL同步加载 #211

Open kvfreedom opened 9 months ago

kvfreedom commented 9 months ago

Addressables的WebGL不支持WaitForCompletion,YooAsset是否在WebGL上也有某些同步加载限制。

gmhevinci commented 9 months ago

是的,这个纯粹是机制问题导致的。所以无法实现。

SonnySmart commented 9 months ago
    /// <summary>
    /// 主线程等待异步操作完毕
    /// </summary>
    public override void WaitForAsyncComplete()
    {
        int frame = 10000;
        while (true)
        {
            // 保险机制
            // 注意:如果需要从WEB端下载资源,可能会触发保险机制!
            // frame帧执行完成还是加载不出来说明性能不行或者包体太大
            frame--;
            if (frame == 0)
            {
                if (_isShowWaitForAsyncError == false)
                {
                    _isShowWaitForAsyncError = true;
                    YooLogger.Error($"{nameof(WaitForAsyncComplete)} failed ! Try load bundle : {MainBundleInfo.Bundle.BundleName} from remote with sync load method !");
                }
                break;
            }

            // 驱动流程
            Update();

            // 驱动流程
            // 这里有个BUG依靠Update()驱动_downloader.Update()帧不会执行因为是主线程驱动
            if (_downloader != null)
            {
                _downloader.Update();
            }

            // 完成后退出
            if (IsDone())
                break;
        }
    }
SonnySmart commented 9 months ago

主线程循环等待加载,没办法烂代码凑合用