Пример #1
0
    private void CreateVersion()
    {
        JsonObject versionInfoJo = new JsonObject();

        versionInfoJo.Add(ConstValue.MODULE_KEY, mModuleName);
        versionInfoJo.Add(ConstValue.VERSION_KEY, ConstValue.VERSION);
        byte[] versionInfoBytes = ConvertExt.StringToBytes(versionInfoJo.ToString());
        FileManager.Write(OUTPUT_PATH + "/" + mModuleName + "/" + ConstValue.VERSION_NAME, versionInfoBytes);

        m_AssetsChanged = true;
    }
Пример #2
0
    private void CreateFileList()
    {
        JsonObject fileListJo = new JsonObject();

        string     manifestPath   = OUTPUT_PATH + "/" + mModuleName + "/" + ConstValue.MANIFEST_NAME + "." + ConstValue.ASSET_BUNDLE_VARIANT;
        FileInfo   manifestFile   = new FileInfo(manifestPath);
        JsonObject manifestInfoJo = new JsonObject();

        manifestInfoJo.Add(ConstValue.FILE_LIST_SIZE_KEY, manifestFile.Length);
        manifestInfoJo.Add(ConstValue.FILE_LIST_MD5_KEY, GetMd5(manifestFile));
        fileListJo.Add(mModuleName.ToLower() + "/" + ConstValue.MANIFEST_NAME + "." + ConstValue.ASSET_BUNDLE_VARIANT, manifestInfoJo);

        AssetBundle manifestAssetBundle = AssetBundle.LoadFromFile(manifestPath);

        if (manifestAssetBundle)
        {
            AssetBundleManifest manifest = manifestAssetBundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest");
            if (manifest)
            {
                foreach (string bundleName in manifest.GetAllAssetBundles())
                {
                    FileInfo file = new FileInfo(OUTPUT_PATH + "/" + bundleName);

                    JsonObject fileInfoJo = new JsonObject();
                    fileInfoJo.Add(ConstValue.FILE_LIST_SIZE_KEY, file.Exists ? file.Length : 0);
                    fileInfoJo.Add(ConstValue.FILE_LIST_MD5_KEY, file.Exists ? GetMd5(file) : "");

                    fileListJo.Add(bundleName, fileInfoJo);
                }
            }
            manifestAssetBundle.Unload(true);
        }
        foreach (string copyDir in s_CopyDirs)
        {
            DirectoryInfo   dir      = new DirectoryInfo(OUTPUT_PATH + "/" + mModuleName + "/" + copyDir);
            List <FileInfo> fileList = dir.Exists ? GetAllFiles(dir, ".", ".meta") : new List <FileInfo>();
            foreach (FileInfo file in fileList)
            {
                JsonObject fileInfoJo = new JsonObject();
                fileInfoJo.Add(ConstValue.FILE_LIST_SIZE_KEY, file.Exists ? file.Length : 0);
                fileInfoJo.Add(ConstValue.FILE_LIST_MD5_KEY, file.Exists ? GetMd5(file) : "");

                string relativePath = copyDir + "/" + file.FullName.Substring(dir.FullName.Length + 1).Replace("\\", "/");
                fileListJo.Add(relativePath, fileInfoJo);
            }
        }

        string fileListStr = ToFileListString(fileListJo);

        byte[] fileListBytes = ConvertExt.StringToBytes(fileListStr);
        FileManager.Write(OUTPUT_PATH + "/" + mModuleName + "/" + ConstValue.FILE_LIST_NAME, fileListBytes);

        m_AssetsChanged = true;
    }