{"id":13661877,"url":"https://github.com/kamanii24/AssetBundleManager","last_synced_at":"2025-04-25T06:30:44.586Z","repository":{"id":219327175,"uuid":"41407306","full_name":"kamanii24/AssetBundleManager","owner":"kamanii24","description":"This script for easily use AssetBundle.","archived":false,"fork":false,"pushed_at":"2019-09-24T07:40:39.000Z","size":112773,"stargazers_count":84,"open_issues_count":0,"forks_count":24,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-11-10T17:45:17.552Z","etag":null,"topics":["assetbundle","c-sharp","unity"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kamanii24.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2015-08-26T05:58:54.000Z","updated_at":"2024-06-13T08:19:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"44a5f46d-2e7b-4de3-9db7-f0486f6dcd38","html_url":"https://github.com/kamanii24/AssetBundleManager","commit_stats":null,"previous_names":["kamanii24/assetbundlemanager"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamanii24%2FAssetBundleManager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamanii24%2FAssetBundleManager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamanii24%2FAssetBundleManager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamanii24%2FAssetBundleManager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kamanii24","download_url":"https://codeload.github.com/kamanii24/AssetBundleManager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250767005,"owners_count":21483905,"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","c-sharp","unity"],"created_at":"2024-08-02T05:01:43.294Z","updated_at":"2025-04-25T06:30:41.549Z","avatar_url":"https://github.com/kamanii24.png","language":"C#","funding_links":[],"categories":["C\\#"],"sub_categories":[],"readme":"# AssetBundleManager\n\n![Imgur](https://i.imgur.com/GD4U1oj.gif)\n\n## 初期設定\nAssetBundleManagerを使用するクラスに using を追加します。\n\n`using KM2;`\n\n## AssetBundleManagerの初期化\n\nAssetBundleManagerを使用する前には必ずInitializeメソッドをコールし、初期化を行う必要があります。\n\n### AssetBundleManifestとAssetBundleが同じ階層に存在する場合\n\nInitializeメソッドの引数に、AssetBundleManifest(AssetBundleビルド時に生成されるプラットフォーム名が付いたファイル)のパスを指定します。\n\n引数にManifestのパスのみを指定した場合、AssetBundleがManifestと同階層にあるとして処理されます。\n\n一度設定すれば以降、設定する必要はありません。\n\n```c#\nAssetBundleManager.Initialize(manifestURL, (bool isComplete)=\u003e\n{\n\t// 初期化完了\n});\n```\n\n### AssetBundleManifestとAssetBundleが異なる階層に存在する場合\n\nAssetBundleがManifestファイルと異なる階層に存在する場合は、引数としてassetBundleDirectoryURLを指定することができます。\n\nこちらも一度設定すれば以降、値の変更しない限り設定し直す必要はありません。\n\n```c#\nAssetBundleManager.Initialize(manifestURL, assetBundleDirectoryURL, (bool isComplete)=\u003e\n{\n\t// 初期化完了\n});\n```\n## AssetBundleのダウンロード\n\n*UnityWebRequest* によるGET通信で *AssetBundleManager.Initialize* で指定したリモートディレクトリから *downloadAssetBundles* 指定したAssetBundleをダウンロードします。  \nコールバック引数でダウンロード対象のAssetBundleのファイルサイズを受け取れるので、進捗値をディスプレイすることが可能です(実装は下記参照)。\n    \n\n```C#\nprivate void Start()\n{\n    string[] downloadAssetBundles = { bundle_1, bundle_2, bundle_3 };\n    AssetBundleManager.DownloadAssetBundle(downloadAssetBundles, Downloading);\n}\n\n// ダウンロード更新\nprivate void Downloading(ulong downloadedBytes, ulong totalBytes, int fileIndex, bool isComplete, string error)\n{\n    // ダウンロードBytesサイズ更新\n    print(downloadedBytes + \" bytes / \"+ totalBytes + \"bytes\");\n\n    // ダウンロード完了\n    if (isComplete)\n    {\n        print(\"Donwload completed.\");\n    }\n}\n```\n\n\n## AssetBundleのロード\n### 関数\n`LoadAssetBundle(string loadAssetBundle, AssetBundleLoaded handler);`\n`LoadAssetBundle(string[] loadAssetBundles, AssetBundleLoaded handler);`\n### デリゲート\n`AssetBundleLoaded(AssetBundle[] loadedAssetBundles, string error);`\n\nロードの完了通知はコールバックデリゲートで受け取れます。\n**loadAssetBundles** で指定したAssetBundleがキャッシュ内に存在しない場合は、ダウンロードします。\n**DownloadAssetBundle**との違いは、delegateで完了通知だけを受け取ることができるので、ダウンロードのプログレス更新が不要な場合や解放されているAssetBundleを個別にロードする場合に使用されます。\n\n```C#\nprivate void Start()\n{\n    string[] loadAssetBundles = { bundle_1, bundle_2, bundle_3 };\n    AssetBundleManager.LoadAssetBundle(loadAssetBundles, Loaded);\n}\n\n// AssetBundleのロード完了\nprivate void Loaded(AssetBundle[] assetBundles, string error)\n{\n    if(error != null)\n    {\n        foreach(var ab in assetBundles) print(ab.name + \" is loaded.\");\n    }\n}\n```\n\n\n\n## ロードしたAssetBundleからアセットを取得する\n**型指定なし**\n\n```C#\nObject obj = AssetBundleManager.GetAsset (bundleName, assetName);\n```\n\n**ジェネリック型指定**\n\n```C#\nAudioClip clip = AssetBundleManager.GetAsset\u003cAudioClip\u003e (bundleName, assetName);\n```\n\n**非同期 ジェネリック型指定**\n\n```C#\nGetAssetAsync\u003cGameObject\u003e (bundleName, assetName, (GameObject go) =\u003e {\n   if (go != null) {\n       Instantiate (go, Vector3.zero, Quaternion.identity);\n   }\n});\n```\n\n## ロードされているAssetBundleを確認する\n**AssetBundle本体**\n\n```C#\nAssetBundle[] ab = AssetBundleManager.GetAllLoadedAssetBundles();\n```\n\n**AssetBundle名**\n\n```C#\nstring[] abNames = AssetBundleManager.GetAllLoadedAssetBundleNames();\n```\n\n## AssetBundleを破棄する\nロードしたAssetBundleは明示的に破棄するまでメモリに保持され続けるため、不要になったAssetBundleは**Unload**で破棄する必要があります。\n\n```C#\nAssetBundleManager.Unload(true);    // trueにした場合、AssetBundleからロード済みのアセットも破棄されます\n```\n\nAssetBundle名を指定して個別に破棄することも可能です。\n\n```C#\nAssetBundleManager.Unload(true, bundleName);\n```\n\n\n\n# ビルド環境\nUnity 2018.4.8f1\nmacOS Mojave 10.14.6\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkamanii24%2FAssetBundleManager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkamanii24%2FAssetBundleManager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkamanii24%2FAssetBundleManager/lists"}