{"id":13663121,"url":"https://github.com/SadPandaStudios/AssetBundleManager","last_synced_at":"2025-04-25T13:31:40.228Z","repository":{"id":42425242,"uuid":"119217334","full_name":"SadPandaStudios/AssetBundleManager","owner":"SadPandaStudios","description":"An asset bundle manager for Unity.","archived":false,"fork":false,"pushed_at":"2024-05-19T23:11:57.000Z","size":62,"stargazers_count":294,"open_issues_count":3,"forks_count":64,"subscribers_count":20,"default_branch":"master","last_synced_at":"2024-11-10T19:34:08.334Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/SadPandaStudios.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-28T01:22:25.000Z","updated_at":"2024-10-30T07:37:33.000Z","dependencies_parsed_at":"2024-11-10T22:15:55.430Z","dependency_job_id":null,"html_url":"https://github.com/SadPandaStudios/AssetBundleManager","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SadPandaStudios%2FAssetBundleManager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SadPandaStudios%2FAssetBundleManager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SadPandaStudios%2FAssetBundleManager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SadPandaStudios%2FAssetBundleManager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SadPandaStudios","download_url":"https://codeload.github.com/SadPandaStudios/AssetBundleManager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250824964,"owners_count":21493370,"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":[],"created_at":"2024-08-02T05:02:18.404Z","updated_at":"2025-04-25T13:31:35.208Z","avatar_url":"https://github.com/SadPandaStudios.png","language":"C#","readme":"# Asset Bundle Manager (ABM)\nYet another asset bundle manager for Unity.\n\n\n## Why\nWe felt the AssetBundleManager provided by Unity was complicated and out-dated... So like typical programmers we decided to write our own!  We wanted something with few frills and easier to trace \u0026 maintain.\n\n\n## Requirements\n - Unity 2018.3 or greater.\n\n\n## Recommendations\nThis module pairs well with Unity's [Asset Bundle Browser](https://github.com/Unity-Technologies/AssetBundles-Browser) (ABB) tool.\n\n\n## How\n\n### Preparation\nFirst you need to build your bundles. By default, the ABB puts bundles in `PROJECT\\AssetBundles\\PLATFORM` and ABM can take advantage of it.\n\nOnce the bundles are built you can start accessing them with the manager.\n\nWhen you are done testing your bundles you need to upload them to a server. They can go anywhere in the server as long as they are contained in a `PLATFORM` folder. For example, builds for iOS bundles should be accessible from `http://www.example.com/AssetBundles/iOS`. The full list of supported targets can be found in [AssetBundleUtility.cs](https://github.com/SadPandaStudios/AssetBundleManager/blob/master/Scripts/AssetBundleUtility.cs).\n\n### Initializing\nABM needs to be initialized before it can access your bundles. Initialization is when ABM downloads and processes the manifest file for your bundles. This lets ABM know what bundles are available and what their dependency chain looks like.\n\nThere are three ways to initialize ABM. Each one returns/contains a boolean to indicate whether the manifest was downloaded successfully or not.\n\n#### Callback\n```csharp\nvar abm = new AssetBundleManager()\n\nif (Application.isEditor)\n    abm.UseSimulatedUri();\nelse\n    abm.SetBaseUri(\"https://www.example.com/bundles\");\n\nabm.Initialize(OnAssetBundleManagerInitialized);\n\nvoid OnAssetBundleManagerInitialized(bool isSuccessful) {\n    if (isSuccessful) \n        // Initialization successful\n}\n\n```\n\n#### Async\n```csharp\nvar abm = new AssetBundleManager()\n\nif (Application.isEditor)\n    abm.UseSimulatedUri();\nelse\n    abm.SetBaseUri(\"https://www.example.com/bundles\");\n\nif (await abm.InitializeAsync()) {\n    // Initialization successful\n}\n```\n\n#### Coroutine\n\n```csharp\nvar abm = new AssetBundleManager();\n\nif (Application.isEditor)\n    abm.UseSimulatedUri();\nelse\n    abm.SetBaseUri(\"https://www.example.com/bundles\");\n\nvar initialize = abm.InitializeAsCoroutine();\nyield return initializeAsync;\n\nif (initializeAsync.Success) {\n    // Initialization successful\n}\n```\n\n`UseSimulatedUri()` configures ABM to use ABB's default folder structure to retrieve bundles. This convenience means you don't have to upload your bundles to a remote server in order to test them, you can use your local files instead.\n\nThe `SetBaseUri(...)` function configures ABM to point to a remote server that contains your bundles.\n\n\n### Downloading\nJust like initializing you can use callbacks, async, or coroutines to download bundles.\n\n#### Callback\n```csharp\npublic function GetMyBundle() \n{\n    abm.GetBundle(\"MyBundle\", OnBundleDownloaded);\n}\n\npublic function OnBundleDownloaded(AssetBundle bundle)\n{\n    if (bundle != null) {\n        // Do something with the bundle\n        abm.UnloadBundle(bundle);\n    }\n}\n```\n\n#### Async\n```csharp\nvar bundle = await abm.GetBundleAsync(\"MyBundle\");\n\nif (bundle != null) {\n    // Do something with the bundle\n    abm.UnloadBundle(bundle);\n}\n```\n\n#### Coroutine\n```csharp\n/// Coroutine\nvar bundle = abm.GetBundleAsAsync(\"MyBundle\");\nyield return bundle;\n\nif (bundle.AssetBundle != null) {\n    // Do something with bundle.AssetBundle\n    abm.UnloadBundle(bundle);\n}\n```\n\nIf ABM is unable to download the bundle it will log an error describing the problem and return a `null` bundle. Therefore it's important to check whether the bundle is `null` before attempting to use it.\n\nBy default bundles are cached using Unity's caching system. The exception to this is the manifest file, which is never cached and always downloaded fresh on initialization. You can override this behaviour on non-manifest bundles by including the DownloadSettings parameter on a GetBundle call:\n\n```csharp\nvar bundle = abm.GetBundle(\"MyBundle\", OnBundleDownloaded, DownloadSettings.DoNotUseCache);\n```\n\nNotice that the above examples call `UnloadBundle(...)` after they are done using the bundle. This is to help ABM manage memory and bundle usage. If two scripts download the same bundle then that bundle is reused for both scripts and will remain in memory until BOTH of those scripts unload the bundle. If memory usage is important to you then you must ensure that every script that loads a bundle also unloads the bundle. If you want to keep the bundle in memory and available at any time then feel free to skip the `UnloadBundle(...)` call.\n\n\n### StreamingAssets\nABM supports pre-caching your bundles with the use of the StreamingAssets folder in Unity. Once your bundles are built you can copy the manifest and any number of bundles to the `StreamingAsests\\PLATFORM` folder in your project. For example if you wanted to pre-cache the `SomeBundle` iOS bundles you would have a structure like:\n\n```\nPROJECT\n  \\Assets\n    \\StreamingAssets\n      \\iOS\n        \\iOS\n        \\iOS.manifest\n        \\SomeBundle\n        \\SomeBundle.manifest\n```\n\nWhen you make a `GetBundle(...)` call ABM will check to see if that bundle exists in the StreamingAssets folder first and use it if its hash matches the hash of the remote server. If the file does not exist OR the hash is different then the remote bundle is used. You can change this behaviour when initializing ABM by changing the prioritization strategy:\n\n```csharp\nabm.SetPrioritizationStrategy(PrioritizationStrategy.PrioritizeStreamingAssets);\n```\n\nThis will tell ABM to always use the StreamingAssets bundle if it exists. If the bundle doesn't exist in StreamingAssets the remote one will be used.\n\n### Cleanup\nThere are two patterns you should follow when using ABM. The first, as mentioned before, is to always unload the bundle when you are finished with it:\n\n```csharp\nabm.UnloadBundle(bundle);\n```\n\nIf no other scripts are using this bundle it will be unloaded from memory. Likewise, when you are completely done with ABM (maybe because you're switching scenes and don't need the bundles anymore) you can dispose of it:\n\n```csharp\nabm.Dispose();\n```\n\nThis will force ALL bundles (and their objects) to be unloaded.","funding_links":[],"categories":["Unity","C\\#","Open Source Repositories","Open Source Packages"],"sub_categories":["Lua","Asset Bundle / Addressable Assets","Asset Bundle"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSadPandaStudios%2FAssetBundleManager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSadPandaStudios%2FAssetBundleManager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSadPandaStudios%2FAssetBundleManager/lists"}