{"id":26770772,"url":"https://github.com/snaticy/assetupdater-core","last_synced_at":"2025-04-15T18:08:56.264Z","repository":{"id":79426373,"uuid":"95802388","full_name":"sNaticY/assetUpdater-core","owner":"sNaticY","description":"AssetUpdater is a Unity plugin which helps developers build assetbundles and download it easily","archived":false,"fork":false,"pushed_at":"2017-09-05T12:22:07.000Z","size":53,"stargazers_count":40,"open_issues_count":0,"forks_count":19,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-15T18:08:49.756Z","etag":null,"topics":["assetbundle","download","unity","unity3d","update"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sNaticY.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-06-29T17:27:25.000Z","updated_at":"2024-12-16T05:56:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"23dccde5-2102-4bca-96ea-24ebf8bf7918","html_url":"https://github.com/sNaticY/assetUpdater-core","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sNaticY%2FassetUpdater-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sNaticY%2FassetUpdater-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sNaticY%2FassetUpdater-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sNaticY%2FassetUpdater-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sNaticY","download_url":"https://codeload.github.com/sNaticY/assetUpdater-core/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249125955,"owners_count":21216705,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assetbundle","download","unity","unity3d","update"],"created_at":"2025-03-28T23:16:33.665Z","updated_at":"2025-04-15T18:08:56.239Z","avatar_url":"https://github.com/sNaticY.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AssetUpdater\n\nAssetUpdater 为开发者提供了方便的生成以及下载 Assetbundle 的工作流。借助该插件，开发者可以一键式的生成 Assetbundle 并在自己的项目中使用几行代码来完成从特定链接下载需要被更新的所有 Assetbundle。\n\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/sNaticY/AssetUpdater-Core/blob/master/LICENSE)\n[![License](https://img.shields.io/badge/pre--release-v0.9-orange.svg)](https://github.com/sNaticY/AssetUpdater-Core/releases)\n\n# 安装\n\n* 方法一：在 Unity 工程 Assets 目录下新建文件夹 AssetUpdater， 下载 Zip 后将所有文件解压至该文件夹即可。\n* 方法二：直接下载 Release 最新版本的 AssetUpater.unitypackage 并将其导入工程即可\n* 方法三：在 Unity 工程中添加 git submodule 并设置相对路径为 Assets/AssetUpdater。\n\n# 快速入门\n\n该插件的主要功能分为 ”生成 Assetbundle“ 和 ”下载 Assetbundle“ 两部分。\n\n### 生成 Assetbundle\n\n导入插件后单击 Unity 菜单栏中的 `Window/AssetUpdater Settings`即可在 Inspector 中显示设置面板。如下图所示：\n\n![AssetUpdater settings](http://osccnzbxn.bkt.clouddn.com/17070701.png)\n\n当你为某些文件设置`assetbundle name`后，该 assetbundle 就会出现在`Local Bundles`或`Remote Bundles`中，其中`Local Bundles`中的 assetbundle 会在生成后被额外复制到`streamingassets`目录下。在打包时随安装包发布，并生成独特的 versionfile 做记录，防止资源重复下载。\n\n选择平台后点击最下方`Build Assetbundles`按钮即可生成 Assetbundle 及其版本信息文件。其中原始的 assetbundle 及其 assetbundlemanifest 文件会被放置在与 Unity 工程中`Assets`目录同级的`AssetBundlePool`文件夹，并将 assetbundle 文件按照原始目录结构复制到与 Unity 工程中`Assets`目录同级的`AssetBundleServer`文件夹中，同时在该文件夹生成版本信息文件，版本信息文件默认文件名为`versionfile.bytes`。`AssetBundleServer`文件夹中的全部内容放置在你的 http 文件服务器中供客户端下载即可。\n\n\u003e 如需要本地测试则可以在`AssetBundleServer`目录运行`sudo python -m SimpleHTTPServer 80`命令，即可开启本地 http 文件服务，访问 http://localhost 即可下载文件。\n\n### 下载 Assetbundle\n\n在`AssetUpdater Seetings`中设置`remote url`为你的 http 文件服务器地址，如需本地测试则设置为 http://localhost 即可。\n\n在 Unity 工程中添加如下代码。\n\n```csharp\nusing Meow.AssetUpdater.Core;\nusing UnityEngine;\n\npublic class TestScript : MonoBehaviour\n{\n\t// Use this for initialization\n\tIEnumerator Start()\n\t{\n\t\tyield return MainUpdater.LoadAllVersionFiles();\n\t\tyield return MainUpdater.UpdateFromStreamingAsset();\n\t\tyield return MainUpdater.UpdateFromRemoteAsset();\n\t}\t\n}\n```\n\n`MainUpdater.LoadAllVersionFiles()`会加载本地 streamingAssetPath 和 persistentDataPath （如果不存在则会自动生成一个）以及 remote url 中所有的 versionfile。\n\n`MainUpdater.UpdateFromStreamingAsset()`则会对比 persistentDataPath 和 streamingAssetPath 中的 versionfile 并将不存在或版本更新的 assetbundle 文件复制至 persistentDataPath 中。复制后将会更新 persistentDataPath 对应的 versionfile 中的信息并将其写入磁盘。每复制完一个 assetbundle 并将其写入磁盘后会立即更新 versionfile。因此即使下载过程中断也不会导致已下载的 assetbundle 下次启动时被重复下载。\n\n`MainUpdater.UpdateFromRemoteAsset()`会对比 persistentDataPath 和 remote Url 中的 versionfile，将不存在或版本更新的 assetbundle 文件复制至 persistentDataPath 中。在生成 assetbundle 时勾选至 Local Bundles 的 assetbundle 文件在上一步已被更新至 persistentDataPath 因此不会重复下载，除非 remote 中的 assetbundle 版本更新。每更新完一个 assetbundle 并将其写入磁盘后会立即更新 versionfile。因此即使下载过程中断也不会导致已下载的 assetbundle 下次启动时被重复下载。\n\n# 主要接口\n\n## Meow.AssetUpdater.Core.MainUpdater\n\n```csharp\n/// \u003csummary\u003e\n/// 初始化 AssetUpdater 全局设置，可用于覆盖 AssetUpdater Settings 中的设置。\n/// \u003c/summary\u003e\n/// \u003cparam name=\"remoteUrl\"\u003e远程 Assetbundle 服务器地址\u003c/param\u003e\n/// \u003cparam name=\"relativePath\"\u003e放置 assetbundle 及 versionfile 的相对路径\u003c/param\u003e\n/// \u003cparam name=\"versionFileName\"\u003eversionfile 的命名，默认为 \"versionfile.bytes\"\u003c/param\u003e\npublic static void Initialize(string remoteUrl, string relativePath, string versionFileName);\n  \n/// \u003csummary\u003e\n/// 下载位于远程服务器、persistentDataPath 以及 streamingAssetPath 中的所有 versionfile，\n/// 用于对比文件状态生成下载列表准备下载\n/// \u003c/summary\u003e\n/// \u003creturns\u003e返回 IEnumrator 可在 coroutine 中通过 \"yield return\" 调用以实现异步操作\u003c/returns\u003e\npublic static IEnumerator LoadAllVersionFiles();\n\n/// \u003csummary\u003e\n/// 从 StreamingAssetPath 或 RemoteUrl 下载 assetbundle 到 persistentDataPath，\n/// 之所以分成两个函数是因为只有 UpdateFromRemoteAsset() 会消耗流量。因此开发者可以考虑\n/// 通过返回的 UpdateOperation 中的对象进行 UI 提示等。\n/// \u003c/summary\u003e\n/// \u003creturns\u003e返回 UpdateOperation 对象提供当前 Update 信息，如下载进度，剩余文件大小等\u003c/returns\u003e\npublic static UpdateOperation UpdateFromStreamingAsset();\npublic static UpdateOperation UpdateFromRemoteAsset();\n\n/// \u003csummary\u003e\n/// 根据资源路径获取其所在的 assetbundle 的名称\n/// \u003c/summary\u003e\n/// \u003cparam name=\"path\"\u003e资源路径\u003c/param\u003e\n/// \u003creturns\u003e返回 assetbundle 的名称\u003c/returns\u003e\npublic static string GetAssetbundleNameByAssetPath(string path)\n```\n\n## Meow.AssetUpdater.Core.UpdateOperation\n\n```csharp\n/// \u003csummary\u003e\n/// 当前正在下载的单个文件的进度 (0,1)\n/// \u003c/summary\u003e\npublic float SingleProgress{ get; }\n\n/// \u003csummary\u003e\n/// 总下载进度 (0,1)\n/// \u003c/summary\u003e\npublic float TotalProgress { get; }\n\n/// \u003csummary\u003e\n/// 当前正在下载的单个文件的已下载部分的大小\n/// \u003c/summary\u003e\npublic int SingleDownloadedSize { get; }\n\n/// \u003csummary\u003e\n/// 当前正在下载的单个文件的原始大小\n/// \u003c/summary\u003e\npublic int SingleSize { get; }\n\n/// \u003csummary\u003e\n/// 已下载的所有文件的大小\n/// \u003c/summary\u003e\npublic long TotalownloadedSize { get; }\n\n/// \u003csummary\u003e\n/// 所有欲下载的文件的总大小\n/// \u003c/summary\u003e\npublic long TotalSize { get; }\n\n/// \u003csummary\u003e\n/// 剩余文件的数量\n/// \u003c/summary\u003e\npublic int RemainBundleCount { get; }\n```\n\n# \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnaticy%2Fassetupdater-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnaticy%2Fassetupdater-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnaticy%2Fassetupdater-core/lists"}