Пример #1
0
    static void FindNewBundle()
    {
        string originalBundlePath = AssetBundleHelper.GetOriginalBundlesPath().Replace("\\", "/") + "/";

        string[] files = Directory.GetFiles(PackageManager.GetAssetBundleDir(), "*", SearchOption.AllDirectories);

        int count = 0;

        for (int i = 0; i < files.Length; i++)
        {
            string filePath = files[i];
            if (filePath.EndsWith(".manifest"))
            {
                continue;
            }

            string relatePath = filePath.Replace("\\", "/").Replace(originalBundlePath, "");

            FileInfo file     = new FileInfo(filePath);
            TimeSpan nowSpan  = new TimeSpan(DateTime.Now.Ticks);
            TimeSpan lastSpan = new TimeSpan(file.LastWriteTime.Ticks);
            if (nowSpan.TotalMilliseconds - lastSpan.TotalMilliseconds < 1000 * 60 * _minutes)
            {
                count++;
                CopyFileToHotfix(file, relatePath);
            }
        }

        Debug.Log("FindNewBundle Count=>" + count);
    }
Пример #2
0
    private static void DownloadOriginalBundles()
    {
        CleanOriginalBundles();

        Stopwatch sw = Stopwatch.StartNew();

        FileUtil.CopyFolder(GetPackagePcRoot + "/" + Folder + "/OriginalBundles", AssetBundleHelper.GetOriginalBundlesPath(), ".manifest");
        Debug.LogWarning("复制OriginalBundles文件时间:" + sw.ElapsedMilliseconds / 1000.0f + "ms");
    }
Пример #3
0
    private static void CleanOriginalBundles()
    {
        string dir = AssetBundleHelper.GetOriginalBundlesPath();

        if (Directory.Exists(dir))
        {
            Directory.Delete(dir, true);
        }
    }
Пример #4
0
    public static void FiltrateCoaxSleepAudio()
    {
        string needDeleteCoaxSleepAudioPath = AssetBundleHelper.NeedDeleteCoaxSleepAudioPath();

        //先把StreamingAssets下的资源删掉
        if (Directory.Exists(needDeleteCoaxSleepAudioPath))
        {
            UnityEditor.FileUtil.DeleteFileOrDirectory(needDeleteCoaxSleepAudioPath);
        }



        string originalBundlePath = AssetBundleHelper.GetOriginalBundlesPath().Replace("\\", "/") + "/";

        string outPathRoot = AssetBundleHelper.GetOutCoaxSleepAudioFolderPath();
        bool   isExists    = Directory.Exists(outPathRoot);

        if (isExists)
        {
            UnityEditor.FileUtil.DeleteFileOrDirectory(outPathRoot);
        }


        Directory.CreateDirectory(outPathRoot);


        //把OriginalBundles的资源拷贝出来
        string findPath = AssetBundleHelper.CopyCoaxSleepAudioPath();

        string[] files = Directory.GetFiles(findPath, "*", SearchOption.AllDirectories);


        for (int i = 0; i < files.Length; i++)
        {
            string filePath = files[i];
            if (filePath.EndsWith(".manifest"))
            {
                continue;
            }
            string relatePath = filePath.Replace("\\", "/").Replace(originalBundlePath, "");

            string destFile = outPathRoot + "/" + relatePath;
            var    fileInfo = new FileInfo(destFile);
            if (fileInfo.Directory.Exists == false)
            {
                fileInfo.Directory.Create();
            }
            File.Copy(filePath, destFile, true);
        }

        CreateCoaxSleepAudioJson(outPathRoot);
    }
Пример #5
0
    private static void CopyDubbingFile(string destDir, string fileName)
    {
        string pathTemp = "/AssetBundles/Android/story/dubbing/";

#if UNITY_IOS
        pathTemp = "/AssetBundles/iOS/story/dubbing/";
#endif
        string srcPath = AssetBundleHelper.GetOriginalBundlesPath() + pathTemp +
                         fileName + ".bytes";

        string destPath = destDir + "/" + fileName + ".bytes";
        File.Copy(srcPath, destPath, true);
    }
Пример #6
0
    static void CopyAllResToStreamingAssets()
    {
        DeleteOuterStreamingAssets_AssetBundles();

        string originalBundlePath  = AssetBundleHelper.GetOriginalBundlesPath().Replace("\\", "/") + "/";
        string streamingAssetsPath = AssetBundleHelper.GetOuterStreamingAssetsPath() + "/";

        string[] files = Directory.GetFiles(PackageManager.GetAssetBundleDir(), "*", SearchOption.AllDirectories);

        int count = 0;
        int len   = files.Length / 2;

        for (int i = 0; i < files.Length; i++)
        {
            string filePath = files[i];
            if (filePath.EndsWith(".manifest"))
            {
                continue;
            }

            string relatePath = filePath.Replace("\\", "/").Replace(originalBundlePath, "");

            string   destFile = string.Empty;
            FileInfo fileInfo = null;

            destFile = streamingAssetsPath + relatePath;
            fileInfo = new FileInfo(destFile);


            if (fileInfo.Directory.Exists == false)
            {
                fileInfo.Directory.Create();
            }

            count++;

            EditorUtility.DisplayProgressBar("复制文件",
                                             "(" + count + "/" + len + ")",
                                             (float)count / len);

            File.Copy(filePath, destFile, true);
        }


        EditorUtility.ClearProgressBar();

        Debug.Log("<color='#00ff00'>复制所有Bundle到StreamingAssets完成</color> 文件数量:" + count);

        FiltrateCoaxSleepAudio();
    }
Пример #7
0
    static void CopyResToStreamingAssets()
    {
        DeleteOuterStreamingAssets_AssetBundles();

        Dictionary <string, bool> fileDict = new Dictionary <string, bool>();

        LoadIndexJson(ResPath.MainStoryIndex, ref fileDict);
        LoadIndexJson(ResPath.LoveStoryIndex, ref fileDict);
        LoadIndexJson(ResPath.EvoCardIndex, ref fileDict);
        LoadIndexJson(ResPath.LoveVisitIndex, ref fileDict);
        LoadIndexJson(ResPath.PhoneAudioPackageIndex, ref fileDict);
        LoadIndexJson(ResPath.AppStart, ref fileDict);
        LoadIndexJson(ResPath.Extend, ref fileDict);
        LoadIndexJson(ResPath.Backend, ref fileDict);
        LoadIndexJson(ResPath.Special, ref fileDict);
        LoadIndexJson(ResPath.IncludeIndex, ref fileDict, true);

        string originalBundlePath  = AssetBundleHelper.GetOriginalBundlesPath().Replace("\\", "/") + "/";
        string streamingAssetsPath = AssetBundleHelper.GetOuterStreamingAssetsPath() + "/";

        string[] files = Directory.GetFiles(PackageManager.GetAssetBundleDir(), "*", SearchOption.AllDirectories);

//        int len = files.Length / 2 - fileDict.Count;

        string destDir = PackageManager.GetPackageDir() + "/" + ResPath.AllResources;

        if (Directory.Exists(destDir))
        {
            Directory.Delete(destDir, true);
        }

        int len            = files.Length / 2;
        int count          = 0;
        int inPackageCount = 0;

        for (int i = 0; i < files.Length; i++)
        {
            string filePath = files[i];
            if (filePath.EndsWith(".manifest"))
            {
                continue;
            }

            string relatePath = filePath.Replace("\\", "/").Replace(originalBundlePath, "");
            if (fileDict.ContainsKey(relatePath))
            {
                string path = PackageManager.GetPackageDir() + "/" + ResPath.AllResources + "/" + relatePath;
                destDir = Path.GetDirectoryName(path);
                if (Directory.Exists(destDir) == false)
                {
                    Directory.CreateDirectory(destDir);
                }

                File.Copy(filePath, path);
            }
            else
            {
                string   destFile = streamingAssetsPath + relatePath;
                FileInfo fileInfo = new FileInfo(destFile);
                if (fileInfo.Directory.Exists == false)
                {
                    fileInfo.Directory.Create();
                }

                File.Copy(filePath, destFile);
                inPackageCount++;
            }

            count++;

            EditorUtility.DisplayProgressBar("复制文件",
                                             "(" + count + "/" + len + ")" + " 包内:" + inPackageCount,
                                             (float)count / len);
        }

        CreateAllDownloadJsonAndZip();

        EditorUtility.ClearProgressBar();

        CopyIndexFileToStreamingAsset();

        Debug.Log("<color='#00ff00'>复制优化后的Bundle到StreamingAssets完成</color> 文件数量:" + count);
    }
Пример #8
0
 public static string GetAssetBundleDir()
 {
     return(AssetBundleHelper.GetOriginalBundlesPath() + "/AssetBundles/" + SystemTag);
 }