Beispiel #1
0
    public static string GetMainAssetBundleName()
    {
        string path         = Get();
        string osFolderName = AssetsCommon.GetPlatformFolderName(UnpackCommon.GetOsType());

        return(string.Format("{0}/{1}", path, osFolderName));
    }
Beispiel #2
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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
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);
        }
    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();
        }
    }