예제 #1
0
        //异步加载
        public void LoadAsync(IXAssetManager manager, EnumFileLocation location, EnumBundleType bundleType, string name, Action <string, AssetBundle> callback = null)
        {
            m_AssetManager = manager;
            m_BundleName   = name;
            m_dependencies.Clear();

            var dependencies = manager.GetDependencies(m_BundleName);

            if (dependencies != null)
            {
                m_dependencies.AddRange(dependencies);
                m_dependencyCurCount = 0;
                m_dependencyMaxCount = dependencies.Count;
                foreach (var dependent in dependencies)
                {
                    manager.LoadBundleAsync(dependent, _OnLoadedDependent);
                }
            }
            var fullPath = XABUtilities.GetBundleFullPath(location, bundleType, name);

            XDebug.Log(XABConst.Tag, $"加载 {fullPath}");
            _StartLoadAsync(fullPath);
            m_state     = EnumJobState.Process;
            m_callback += callback;
        }
        protected void _OnDownloadComplete(string error, byte[] data)
        {
            m_state = EnumJobState.Done;

            if (data == null)
            {
                return;
            }
            var name = m_curDownload;

            m_manager.AssetInfoManager.SetLocation(name, EnumFileLocation.Client);

            //保存下载文件
            var path = XABUtilities.GetResPath(EnumFileLocation.Client, EnumBundleType.Hotfix);

            XUtilities.SaveFile($"{path}/{name}", data);

            var hotfixInfo = m_manager.AssetInfoManager.hotfixInfo;
            //保存filelist
            var client_filelist = hotfixInfo.client_filelist;
            var server_filelist = hotfixInfo.server_filelist;
            var serverFileInfo  = server_filelist.GetFileInfo(name);
            var clientFileInfo  = client_filelist.GetFileInfo(name);

            if (clientFileInfo == null)
            {
                clientFileInfo = new XFileList.XFileInfo();
                client_filelist.AddFileInfo(name, clientFileInfo);
            }
            clientFileInfo.name   = name;
            clientFileInfo.path   = serverFileInfo.path;
            clientFileInfo.length = serverFileInfo.length;
            clientFileInfo.md5    = serverFileInfo.md5;
            XFileList.SaveFileList(XABUtilities.GetResPath(EnumFileLocation.Client, EnumBundleType.Hotfix), client_filelist);
        }
        public override void Enter()
        {
            var clientHotfixPath = XABUtilities.GetResPath(EnumFileLocation.Client, EnumBundleType.Hotfix);

            if (XABUtilities.ExistManifest(clientHotfixPath))
            {
                m_manager.AssetInfoManager.SetHotfixManifest(XABUtilities.ReadManifest(clientHotfixPath));
                return;
            }
            var streamHotfixPath = XABUtilities.GetResPath(EnumFileLocation.Stream, EnumBundleType.Hotfix);

            if (XABUtilities.ExistManifest(streamHotfixPath))
            {
                m_manager.AssetInfoManager.SetHotfixManifest(XABUtilities.ReadManifest(streamHotfixPath));
                return;
            }
        }
예제 #4
0
        //同步加载
        public void Load(IXAssetManager manager, EnumFileLocation location, EnumBundleType bundleType, string name)
        {
            m_AssetManager = manager;
            m_BundleName   = name;

            m_dependencies.Clear();
            var dependencies = manager.GetDependencies(m_BundleName);

            if (dependencies != null)
            {
                m_dependencies.AddRange(dependencies);
                foreach (var dependency in dependencies)
                {
                    manager.LoadBundle(dependency);
                }
            }
            var fullPath = XABUtilities.GetBundleFullPath(location, bundleType, name);

            XDebug.Log(XABConst.Tag, $"加载 {fullPath}");
            SetValue(_LoadInternal(fullPath));
        }
예제 #5
0
        public override void Enter()
        {
            var assetInfoManager = m_manager.AssetInfoManager;

            m_serverAddress = m_manager.serverAddress;
#if UNITY_EDITOR
            m_serverAddress = EditorPrefs.GetString(XABConst.EKResUrl);
            if (string.IsNullOrEmpty(m_serverAddress))
            {
                Debug.LogError("没有配置url");
                return;
            }
            m_serverAddress += "/_filelist.json";
#endif
            m_server_filelist = null;
            m_client_filelist = XFileList.LoadFileList(XABUtilities.GetResPath(EnumFileLocation.Client, EnumBundleType.Hotfix));
            m_origin_filelist = XFileList.LoadFileList(XABUtilities.GetResPath(EnumFileLocation.Stream, EnumBundleType.Hotfix));
            if (m_client_filelist == null)
            {
                m_client_filelist = new XFileList();
            }
            if (m_origin_filelist == null)
            {
                m_origin_filelist = new XFileList();
            }

            XWebRequestManagerSingle.GetUrl(m_serverAddress,
                                            delegate(string error, string responseData)
            {
                if (!string.IsNullOrEmpty(error))
                {
                    return;
                }
                m_server_filelist = JsonUtility.FromJson <XFileList>(responseData);
                XDebug.Log(XABConst.Tag, m_server_filelist.ToLog());
            });
        }
예제 #6
0
 public XAssetManagerOrdinary()
 {
     m_AssetInfoManager = new XABAssetInfoManager();
     m_AssetInfoManager.SetStaticManifest(XABUtilities.ReadManifest(XABUtilities.GetResPath(EnumFileLocation.Stream, EnumBundleType.Static)));
     m_InitTaskSchedule = new XABHotfixTaskSchedule(this);
 }