コード例 #1
0
        void LoadBundle()
        {
            string assetPath = AssetPaths.GetFullPath(info.fullName);

#if ASSETMANAGER_LOG_ON
            Debug.Log("[AssetManage]LoadBundle " + assetPath + "," + Time.frameCount);
#endif
            LoadFromFileSync(assetPath);
        }
コード例 #2
0
ファイル: AssetManager.cs プロジェクト: trarck/AssetsManager
        public void Init(string allManifestFile = null, Action <bool> callback = null)
        {
            if (m_Inited)
            {
                if (m_InfoManager.inited)
                {
                    if (callback != null)
                    {
                        callback(true);
                    }
                }
                else
                {
                    m_InfoManager.onInitComplete += callback;
                }
                return;
            }
            m_Inited = true;

            //asset search path
            AssetPaths.SetupDefaultSearchPaths();

            //system events
            SetupSystemEvents();

            //crate loader manager
            m_LoaderManager = new LoaderManager(this);

            //create rquest manager
            m_RequestManager = new RequestManager(this);
            m_RequestManager.Init();

            //create info manager
            m_InfoManager = new InfoManager(this);
            m_InfoManager.Init();
            if (callback != null)
            {
                m_InfoManager.onInitComplete += callback;
            }

            if (string.IsNullOrEmpty(allManifestFile))
            {
                allManifestFile = AssetPaths.bundleManifestFile;
            }
            m_InfoManager.Load(AssetPaths.GetFullPath(allManifestFile));
        }
コード例 #3
0
        public virtual Request CreateAssetBundleRequest(AssetBundleInfo assetBundleInfo)
        {
            if (assetBundleInfo == null)
            {
                return(null);
            }

            if (m_CacheManager != null)
            {
                //use cache
                if (m_CacheManager.IsCached(assetBundleInfo.fullName, assetBundleInfo.hash))
                {
                    //load from cache
                    string assetPath = AssetPaths.GetFullPath(assetBundleInfo.fullName);
                    return(CreateBundleCreateRequest(assetPath));
                }
                else
                {
                    //download and save to cache
                    string url      = AssetPaths.GetUrl(assetBundleInfo.fullName);
                    string savePath = AssetPaths.ToBundlePath(assetBundleInfo.fullName);
                    BundleWebSaveRequest webSaveRequest = CreateBundleWebSaveRequest(url, savePath, assetBundleInfo.hash, assetBundleInfo.fullName);
                    webSaveRequest.onSaveComplete += OnBundleWebRequestSaveComplete;
                    return(webSaveRequest);
                }
            }
            else
            {
                //no cache
                string assetPath = AssetPaths.GetFullPath(assetBundleInfo.fullName);
#if ASSETMANAGER_LOG_ON
                Debug.LogFormat("[AssetManage]LoadBundle {0}---{1}", assetPath, Time.frameCount);
#endif
                if (assetPath.Contains("://"))
                {
                    return(CreateBundleWebRequest(assetPath));
                }
                else
                {
                    return(CreateBundleCreateRequest(assetPath));
                }
            }
        }