コード例 #1
0
        public AssetBundleLoader LoadAssetAsync(string assetPath, Action <AssetBundleInfo> OnComplete, bool isMulti = false, object param = null)
        {
            string            filePath     = AssetBundlePathResolver.GetAssetPath(assetPath.ToLower());
            AssetBundleLoader bundleLoader = CreateAssetBundleLoader(filePath, param, isMulti, true);

            if (null == bundleLoader)
            {
                if (null != OnComplete)
                {
                    OnComplete(null);
                }
            }
            else
            {
                allLoadSet.Add(bundleLoader);
                if (bundleLoader.IsComplete)
                {
                    if (null != OnComplete)
                    {
                        bundleLoader.bundleInfo.param = param;

                        OnComplete(bundleLoader.bundleInfo);
                    }
                }
                else
                {
                    if (null != OnComplete)
                    {
                        bundleLoader.onLoadComplete += OnComplete;
                    }

                    if (bundleLoader.state < EBundleLoadState.EState_Loading)
                    {
                        unCompleteLoadSet.Add(bundleLoader);
                    }
                    StartLoadBundle();
                }
            }

            return(bundleLoader);
        }
コード例 #2
0
        public void LoadAssetSync(string assetPath, Action <AssetBundleInfo> OnComplete, bool isMulti = false, object param = null)
        {
            string filePath = AssetBundlePathResolver.GetAssetPath(assetPath.ToLower());

            AssetBundleLoader bundleLoader = CreateAssetBundleLoader(filePath, param, isMulti, false);

            if (bundleLoader.IsComplete)
            {
                if (null != OnComplete)
                {
                    OnComplete(bundleLoader.bundleInfo);
                }
            }
            else
            {
                if (null != OnComplete)
                {
                    bundleLoader.onLoadComplete += OnComplete;
                }

                bundleLoader.LoadSync();
            }
        }