Exemplo n.º 1
0
        protected override void OnAsyncRequestUpdate(AsyncRequest request)
        {
            var result = request.result;

            string[] assetPaths = request.paths;
            for (int i = 0; i < assetPaths.Length; i++)
            {
                if (result.IsDoneAt(i))
                {
                    continue;
                }

                string    assetPath = assetPaths[i];
                AssetNode assetNode = assetNodeDic[assetPath];
                if (assetNode.IsLoaded())
                {
                    if (request.isInstance)
                    {
                        request.SetUObject(i, assetNode.CreateInstance());
                    }
                    else
                    {
                        request.SetUObject(i, assetNode.GetAsset());
                    }
                    assetNode.ReleaseRef();
                    continue;
                }
                else
                {
                    string     bundlePath = assetDetailConfig.GetBundleByPath(assetPath);
                    BundleNode bundleNode = bundleNodeDic[bundlePath];
                    if (bundleNode.IsDone && !assetOperationDic.ContainsKey(assetPath))
                    {
                        BundleAssetAsyncOperation assetOperation = assetOperationPool.Get();
                        assetOperation.DoInitilize(assetPath);
                        assetOperation.OnOperationComplete = OnAssetFromBundleCreated;

                        assetOperationDic.Add(assetPath, assetOperation);
                        operationLDic.Add(assetPath, assetOperation);
                    }
                    request.SetProgress(i, GetAsyncAssetProgress(assetPath));
                }
            }
            if (result.IsDone())
            {
                if (request.isInstance)
                {
                    request.state = RequestState.InstanceFinished;
                }
                else
                {
                    request.state = RequestState.LoadFinished;
                }
            }
        }
Exemplo n.º 2
0
        private void OnAssetFromBundleCreated(AAsyncOperation operation)
        {
            BundleAssetAsyncOperation assetOperation = (BundleAssetAsyncOperation)operation;
            string assetPath = operation.Path;

            if (assetNodeDic.TryGetValue(assetPath, out var assetNode))
            {
                assetNode.SetAsset(assetOperation.GetAsset());
            }
            assetOperationDic.Remove(assetPath);
            operationLDic.Remove(assetPath);
            assetOperationPool.Release(assetOperation);
        }