コード例 #1
0
        public UnityObject LoadAssetSync(string address)
        {
            string    assetPath = assetDetailConfig.GetPathByAddress(address);
            AssetNode assetNode = GetAssetNodeSync(assetPath);

            return(assetNode.GetAsset());
        }
コード例 #2
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;
                }
            }
        }
コード例 #3
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
                {
                    if (!operationLDic.TryGetValue(assetPath, out var assetOperation))
                    {
                        assetOperation = assetOperationPool.Get();
                        assetOperation.DoInitilize(assetPath);
                        assetOperation.OnOperationComplete = OnAssetLoadCompleted;

                        operationLDic.Add(assetPath, assetOperation);
                    }

                    request.SetProgress(i, assetOperation.Progress);
                }
            }
            if (result.IsDone())
            {
                if (request.isInstance)
                {
                    request.state = RequestState.InstanceFinished;
                }
                else
                {
                    request.state = RequestState.LoadFinished;
                }
            }
        }