Beispiel #1
0
        public static string GetPackageFullFileName(ABPathInfo pathInfo, int index)
        {
            string assetPath = GetFenBaoPath(pathInfo);
            string fileName  = PathConstant.FileName.GetPackage(pathInfo.Version, index);

            return(AssetsCommon.BuildFileName(assetPath, fileName));
        }
Beispiel #2
0
        public static string GetAssetBundleFileName(
            ePlatformType osType, string fileName)
        {
            string url = GetABCacheURL(osType);

            return(AssetsCommon.BuildFileName(url, fileName));
        }
Beispiel #3
0
    public static string GetMainAssetBundleName()
    {
        string path         = Get();
        string osFolderName = AssetsCommon.GetPlatformFolderName(UnpackCommon.GetOsType());

        return(string.Format("{0}/{1}", path, osFolderName));
    }
Beispiel #4
0
    public void Setup()
    {
        _is_current_loader = new List <AssetBundleInfo>();
        _asset_bundles     = new Dictionary <string, AssetBundleInfo>();
        _dependency        = new AssetDependency();

        string assetPath = AssetsCommon.LocalAssetPath + "/" + AssetsCommon.GetPlatform();

        if (!File.Exists(assetPath))
        {
            return;
        }

        _main     = AssetBundle.LoadFromFile(assetPath);
        _manifest = _main.LoadAsset <AssetBundleManifest>("AssetBundleManifest");

        string[] assetBundles = _manifest.GetAllAssetBundles();

        for (int i = 0; i < assetBundles.Length; i++)
        {
            string assetBundleName = assetBundles[i].ToLower();

            _asset_bundles.Add(assetBundleName, new AssetBundleInfo(assetBundleName));
            string[] dependencies = _manifest.GetAllDependencies(assetBundleName);
            _dependency.Add(assetBundleName, dependencies);
        }

        _main.Unload(false);
    }
Beispiel #5
0
        public static string GetPackageFileName(
            ABPathInfo pathInfo, string fileName)
        {
            string url = GetFenBaoURL(pathInfo);

            return(AssetsCommon.BuildFileName(url, fileName));
        }
Beispiel #6
0
        // 例如:AssetBundlerServer/FenBao/Win/version_1/package0_i
        public static string GetFenBaoPath(ABPathInfo pathInfo)
        {
            string assetPath         = AssetsCommon.GetAssetPath();
            string assetFolderName   = PathConstant.FolderName.FEN_BAO;
            string osFolderName      = AssetsCommon.GetPlatformFolderName(pathInfo.OsType);
            string versionFolderName = PathConstant.FolderName.GetFenBaoVersion(pathInfo.Version);

            if (osFolderName == string.Empty)
            {
                Debug.LogError("平台文件夹名称获取错误:" + pathInfo.OsType);
                return(string.Empty);
            }

            List <string> paths = new List <string>()
            {
                PathConstant.SERVER_FOLDER_NAME,
                assetFolderName,
                osFolderName,
                versionFolderName
            };

            string path = AssetsCommon.BuildPath(assetPath, paths);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            return(path);
        }
Beispiel #7
0
        public static string GetABCacheURL(ePlatformType osType)
        {
            string assetFolderName = PathConstant.FolderName.AB_CACHE;
            string osFolderName    = AssetsCommon.GetPlatformFolderName(osType);

            List <string> paths = new List <string>()
            {
                assetFolderName,
                osFolderName
            };

            return(AssetsCommon.BuildPath(URL, paths));
        }
Beispiel #8
0
        public static string GetVersionListURL(ePlatformType osType)
        {
            string assetFolderName = PathConstant.FolderName.FILE_MANIFEST;
            string osFolderName    = AssetsCommon.GetPlatformFolderName(osType);

            List <string> paths = new List <string>()
            {
                assetFolderName,
                osFolderName
            };
            string url = AssetsCommon.BuildPath(URL, paths);

            return(AssetsCommon.BuildFileName(url, PathConstant.FileName.VERSION_LIST));
        }
Beispiel #9
0
        public static string GetFenBaoURL(ABPathInfo pathInfo)
        {
            string assetFolderName   = PathConstant.FolderName.FEN_BAO;
            string osFolderName      = AssetsCommon.GetPlatformFolderName(pathInfo.OsType);
            string versionFolderName = PathConstant.FolderName.GetFenBaoVersion(pathInfo.Version);

            List <string> paths = new List <string>()
            {
                assetFolderName,
                osFolderName,
                versionFolderName
            };

            return(AssetsCommon.BuildPath(URL, paths));
        }
Beispiel #10
0
        public static string GetFileManifestURL(ABPathInfo pathInfo)
        {
            string assetFolderName   = PathConstant.FolderName.FILE_MANIFEST;
            string osFolderName      = AssetsCommon.GetPlatformFolderName(pathInfo.OsType);
            string versionFolderName = PathConstant.FolderName.GetVersion(pathInfo.Version);

            List <string> paths = new List <string>()
            {
                assetFolderName,
                osFolderName,
                versionFolderName
            };

            return(AssetsCommon.BuildPath(URL, paths));
        }
Beispiel #11
0
    public static void AddHttpHeader(
        HttpWebRequest webRequest,
        eDownLoadType downLoadType,
        string version)
    {
        int versionNumber = 0;

        if (version != string.Empty)
        {
            string[] versionContext = version.Split('.');
            if (downLoadType == eDownLoadType.ZipFile)
            {
                versionNumber = System.Convert.ToInt32(versionContext[0]);
            }
            else if (downLoadType == eDownLoadType.FileManifest)
            {
                versionNumber = System.Convert.ToInt32(versionContext[1]);
            }
        }

        // DownLoadType
        webRequest.Headers.Add("DType",
                               string.Format("{0}={1}",
                                             DownloaderConstant.DOWNLOAD_TYPE,
                                             downLoadType));

        // DownLoadSpeed
        webRequest.Headers.Add("DLSpeed",
                               string.Format("{0}={1}",
                                             DownloaderConstant.DOWNLOAD_SPEED,
                                             DownloaderConstant.DownLoadSpeed));

        // Version
        webRequest.Headers.Add("Version",
                               string.Format("{0}={1}",
                                             "Version",
                                             versionNumber));

        // OsType
        ePlatformType osType = AssetsCommon.GetPlatform();

        webRequest.Headers.Add("PlatformType",
                               string.Format("{0}={1}",
                                             "OsType",
                                             osType));
    }
Beispiel #12
0
    public static string Get()
    {
        string dataPath     = Application.streamingAssetsPath;
        string osFolderName = AssetsCommon.GetPlatformFolderName(UnpackCommon.GetOsType());

        List <string> folders = new List <string>()
        {
            osFolderName
        };

        string path = AssetsCommon.BuildPath(dataPath, folders);

        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
        }

        return(path);
    }
Beispiel #13
0
    public static string GetABFile(string assetName)
    {
        ePlatformType osType = UnpackCommon.GetOsType();

        string dataPath     = Application.streamingAssetsPath;
        string osFolderName = AssetsCommon.GetPlatformFolderName(osType);

        List <string> folders = new List <string>()
        {
            osFolderName
        };
        string path = AssetsCommon.BuildPath(dataPath, folders);

        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
        }

        return(AssetsCommon.BuildFileName(path, assetName));
    }
Beispiel #14
0
        public static string GetVersionListPath(ePlatformType osType)
        {
            string assetPath       = AssetsCommon.GetAssetPath();
            string assetFolderName = PathConstant.FolderName.FILE_MANIFEST;
            string osFolderName    = AssetsCommon.GetPlatformFolderName(osType);

            List <string> paths = new List <string>()
            {
                PathConstant.SERVER_FOLDER_NAME,
                assetFolderName,
                osFolderName
            };
            string path = AssetsCommon.BuildPath(assetPath, paths);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            return(path);
        }
Beispiel #15
0
        public static string GetABAssetInfoFileName(ABPathInfo pathInfo)
        {
            string assetPath = GetFileManifestPath(pathInfo);

            return(AssetsCommon.BuildFileName(assetPath, PathConstant.FileName.AB_ASSET_INFO));
        }
Beispiel #16
0
        public static string GetVersionListFileName(ePlatformType osType)
        {
            string assetPath = GetVersionListPath(osType);

            return(AssetsCommon.BuildFileName(assetPath, PathConstant.FileName.VERSION_LIST));
        }
Beispiel #17
0
        public static string GetFenBaoFileName(ABPathInfo pathInfo)
        {
            string assetPath = GetFileManifestPath(pathInfo);

            return(AssetsCommon.BuildFileName(assetPath, PathConstant.FileName.FEN_BAO));
        }
    public void Save(PackageType packageType)
    {
        // 写入版本
        _local_version             = new VersionInfo();
        _local_version.Version     = UnpackCommon.GetSettingInfo().Version;
        _local_version.OsType      = UnpackCommon.Target.ToString();
        _local_version.CurrentTime = System.DateTime.Now.ToString();
        _local_version.Type        = packageType.ToString(); //默认散包

        // 写入assetbundlemanifest

        string unpackPath          = UnpackPath.Get();
        string mainAssetBundleName = string.Format("{0}/{1}", unpackPath, UnpackCommon.GetOsType());
        string mainManifestName    = string.Format("{0}/{1}.manifest", unpackPath, UnpackCommon.GetOsType());

        long mainAssetBundleLength = 0;
        long mainManifestLength    = 0;

        string mainABMD5       = string.Empty;
        string mainManifestMD5 = string.Empty;

        if (File.Exists(mainAssetBundleName))
        {
            using (FileStream fs = File.Open(mainAssetBundleName, FileMode.Open))
            {
                mainAssetBundleLength = fs.Length;
                mainABMD5             = FileUtils.GetFileMD5ByStream(fs);
                fs.Close();
            }
        }

        if (File.Exists(mainManifestName))
        {
            using (FileStream fs = File.Open(mainManifestName, FileMode.Open))
            {
                mainManifestLength = fs.Length;
                mainManifestMD5    = FileUtils.GetFileMD5ByStream(fs);
                fs.Close();
            }
        }

        string fileName = AssetsCommon.GetPlatformFolderName(AssetsCommon.GetPlatform());

        _local_version.AssetBundleManifestNames   = new string[2];
        _local_version.AssetBundleManifestLengths = new string[2];
        _local_version.AssetBundleManifestMD5s    = new string[2];

        _local_version.AssetBundleManifestNames[0] = fileName;
        _local_version.AssetBundleManifestNames[1] = string.Format("{0}.manifest", fileName);

        _local_version.AssetBundleManifestLengths[0] = mainAssetBundleLength.ToString();
        _local_version.AssetBundleManifestLengths[1] = mainManifestLength.ToString();

        _local_version.AssetBundleManifestMD5s[0] = mainABMD5;
        _local_version.AssetBundleManifestMD5s[1] = mainManifestMD5;

        string jsonStr     = JsonUtility.ToJson(_local_version);
        string versionPath = AssetBundleServerPath.FileManifest.GetVersionFileName(UnpackCommon.DefaultABPath);

        if (File.Exists(versionPath))
        {
            File.Delete(versionPath);
        }

        using (FileStream stream = File.Create(versionPath))
        {
            byte[] bytes = Encoding.Default.GetBytes(jsonStr);
            stream.Write(bytes, 0, bytes.Length);
            stream.Close();
        }


        bool hasVersion = false;

        for (int i = 0; i < _all_version_number.Count; i++)
        {
            if (_all_version_number[i] == _local_version.Version)
            {
                hasVersion = true;
                break;
            }
        }

        if (!hasVersion)
        {
            _all_version_number.Add(_local_version.Version);
        }

        string versionListPath = AssetBundleServerPath.FileManifest.GetVersionListFileName(UnpackCommon.GetOsType());

        if (File.Exists(versionListPath))
        {
            File.Delete(versionListPath);
        }

        using (FileStream fs = File.Create(versionListPath))
        {
            string context = string.Empty;
            for (int i = 0; i < _all_version_number.Count; i++)
            {
                if (i == _all_version_number.Count - 1)
                {
                    context += _all_version_number[i];
                }
                else
                {
                    context += _all_version_number[i] + "\n";
                }
            }

            byte[] bytes = System.Text.Encoding.Default.GetBytes(context);
            fs.Write(bytes, 0, bytes.Length);
            fs.Close();
        }
    }
    public override string GetURL()
    {
        ABPathInfo pathInfo = new ABPathInfo(AssetsCommon.GetPlatform(), version);

        return(AssetBundleServerPath.FileManifestURL.GetABAssetInfoURL(pathInfo));
    }
 public string GetURL()
 {
     return(AssetBundleServerPath.FileManifestURL.GetVersionListURL(AssetsCommon.GetPlatform()));
 }
 public string GetURL()
 {
     return(AssetBundleServerPath.ABCacheURL.GetAssetBundleFileName(AssetsCommon.GetPlatform(), assetName));
 }
    public string GetURL()
    {
        ABPathInfo pathInfo = new ABPathInfo(AssetsCommon.GetPlatform(), version);

        return(AssetBundleServerPath.FenBaoURL.GetPackageFileName(pathInfo, assetName));
    }
Beispiel #23
0
        public static string GetABAssetInfoURL(ABPathInfo pathInfo)
        {
            string url = GetFileManifestURL(pathInfo);

            return(AssetsCommon.BuildFileName(url, PathConstant.FileName.AB_ASSET_INFO));
        }
Beispiel #24
0
        public static string GetVersionFileName(ABPathInfo pathInfo)
        {
            string assetPath = GetFileManifestPath(pathInfo);

            return(AssetsCommon.BuildFileName(assetPath, PathConstant.FileName.VERSION));
        }
Beispiel #25
0
        public static string GetVersionURL(ABPathInfo pathInfo)
        {
            string url = GetFileManifestURL(pathInfo);

            return(AssetsCommon.BuildFileName(url, PathConstant.FileName.VERSION));
        }
Beispiel #26
0
        public static string GetFenBaoURL(ABPathInfo pathInfo)
        {
            string url = GetFileManifestURL(pathInfo);

            return(AssetsCommon.BuildFileName(url, PathConstant.FileName.FEN_BAO));
        }