Пример #1
0
    public static void DoBuildAssetBundles()
    {
        BuildPipeline.BuildAssetBundles(Application.dataPath + "/AssetBundles", BuildAssetBundleOptions.None, platformTarget);

        string newFile = Application.dataPath + "/AssetBundles/" + versionFile;

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

        string[]     files   = Directory.GetFiles(Application.dataPath + "/AssetBundles", "*", SearchOption.AllDirectories);
        FileStream   fs      = new FileStream(newFile, FileMode.CreateNew);
        StreamWriter version = new StreamWriter(fs);

        for (int i = 0; i < files.Length; ++i)
        {
            string fileParth = files[i];
            if (fileParth.EndsWith(".meta") || fileParth.EndsWith(".manifest"))
            {
                continue;
            }
            else
            {
                string name = fileParth.Replace(Application.dataPath + "/AssetBundles\\", "");
                Debug.Log(name);
                string md5 = MD5Hash.GetFileMD5Hash(Application.dataPath + "/AssetBundles/" + name);
                version.WriteLine(name + "|" + md5);
            }
        }
        version.Close();
        fs.Close();
        AssetDatabase.Refresh();
    }