{"id":13662454,"url":"https://github.com/inc8877/AddressablesMaster","last_synced_at":"2025-04-25T10:31:37.319Z","repository":{"id":127070432,"uuid":"401093694","full_name":"inc8877/AddressablesMaster","owner":"inc8877","description":"Manage Addressables using Sync, Async(.NET / UniTask), Coroutine, Lifetime Managing systems with results caching","archived":false,"fork":false,"pushed_at":"2024-08-28T13:41:59.000Z","size":92,"stargazers_count":36,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-08-28T15:05:18.333Z","etag":null,"topics":["addressables","async","coroutines","lifetime","management","manager","sync","unity"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inc8877.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2021-08-29T16:49:50.000Z","updated_at":"2024-08-28T13:39:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"cbff1c54-92d3-4a89-87dc-343c6601017f","html_url":"https://github.com/inc8877/AddressablesMaster","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inc8877%2FAddressablesMaster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inc8877%2FAddressablesMaster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inc8877%2FAddressablesMaster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inc8877%2FAddressablesMaster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inc8877","download_url":"https://codeload.github.com/inc8877/AddressablesMaster/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223996668,"owners_count":17238345,"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":["addressables","async","coroutines","lifetime","management","manager","sync","unity"],"created_at":"2024-08-02T05:01:59.095Z","updated_at":"2024-11-10T18:30:35.581Z","avatar_url":"https://github.com/inc8877.png","language":"C#","funding_links":[],"categories":["C\\#"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/29813954/131343434-0b4c9271-7c13-49b6-a753-b084f1cd78cc.png\" width=\"600\" height=\"350\" /\u003e \u003c/p\u003e\n\n## About\n\nManage Addressables using Sync, Async(Built-in/UniTask), Coroutine, Lifetime Managing systems.\n\nThis solution will provide you with simple and convenient operations for Addressables assets management with results caching.\nYou have a synchronous, asynchronous, coroutine use-case at your disposal.\nAlso, if you are concerned about preventing memory leaks, you can use `lifetime` management tools to release an unused asset in time.\n\nIf you find this project useful, star it, I will be grateful!\n\n## Table of Contents\n- [About](#about)\n- [Table of Contents](#table-of-contents)\n- [Roadmap](#roadmap)\n- [Installation](#installation)\n  - [Install via OpenUPM](#install-via-openupm)\n  - [Install via Git URL](#install-via-git-url)\n- [How to use](#how-to-use)\n  - [Intro](#intro)\n  - [Short examples](#short-examples)\n  - [Lifetime managment](#lifetime-managment)\n    - [Addressables Extensions](#addressables-extensions)\n    - [Management operations](#management-operations)\n    - [Short examples](#short-examples-1)\n- [Credits](#credits)\n\n## Roadmap\n\n|  Status   | Milestone                |\n| :-------: | :----------------------- |\n| :rocket:  | Comment out all code     |\n| :rocket:  | Reduce memory allocation |\n| :pushpin: | Completely docs          |\n\n## Installation\n\n### Install via OpenUPM\n\nThe package is available on the [openupm](https://openupm.com) registry. It's recommended to install it via [openupm-cli](https://github.com/openupm/openupm-cli).\n\n```bash\nopenupm add com.inc8877.addressables-master\n```\n\n### Install via Git URL\n\nOpen `Packages/manifest.json` with your favorite text editor. Add the following line to the dependencies block.\n\n```json\n{\n  \"dependencies\": {\n    \"com.inc8877.addressables-master\": \"https://github.com/inc8877/AddressablesMaster.git\",\n   }\n}\n```\n\n## How to use\n\n### Intro\n\nPlug in namespace first.\n\n```c#\nusing AddressablesMaster;\n```\n\nAll basic features for asset management are available along the following path:\n\n```c#\nManageAddressables.[SOME_COMMAND];\n```\n\nBelow is a list of operations that are available in each control model:\n\n- Initialize\n- LoadLocations\n- LoadAsset\n- LoadScene\n- UnloadScene\n- Instantiate\n- InstantiateWithAutoRelease\n\nIf you are using the `UniTask` in a project and want to use it in an asynchronous control model, then connect it by following the path `Tools \u003e Addressables Master \u003e UniTask \u003e On`.\n`.NET` asynchronous operating model is used by default.\n\u003e Carefully! If you switch the asynchronous model, all existing code will be invalidated as each model has its own implementation.\n\n### Short examples\n\nFor examples we will take some data:\n\n```c#\n// Some data for examples\npublic string startupSound;\npublic AssetReferenceGameObject props;\npublic AssetReferenceMaterial material;\npublic AudioSource audioSource;\n\n[Serializable]\npublic class AssetReferenceMaterial : AssetReferenceT\u003cMaterial\u003e\n{\n  public AssetReferenceMaterial(string guid) : base(guid) { }\n}\n```\n\n`Sync`\n\n```c#\naudioSource.PlayOneShot(ManageAddressables.LoadAssetSync\u003cAudioClip\u003e(startupSound));\n            \nvar _material = ManageAddressables.LoadAssetSync(material);\n            \nManageAddressables.InstantiateSync(props).GetComponent\u003cMeshRenderer\u003e().material = _material;\n```\n\n`Async .NET`\n\n```c#\nManageAddressables.LoadAssetAsync(material, _material =\u003e ManageAddressables.InstantiateAsync(props,\n                onCompletion: _go =\u003e _go.GetComponent\u003cMeshRenderer\u003e().material = _material));\n```\n\n`Async UniTask`\n\n```c#\nManageAddressables.LoadAssetAsync(material).ContinueWith(result =\u003e\n            ManageAddressables.InstantiateAsync(props).ContinueWith(x =\u003e\n            x.Value.GetComponent\u003cMeshRenderer\u003e().material = result));\n```\n\n`Coroutine`\n\n```c#\nStartCoroutine(ManageAddressables.LoadAssetCoroutine(material, (key1, result1) =\u003e\n                StartCoroutine(ManageAddressables.InstantiateCoroutine(props,\n                    onSucceeded: (key2, result2) =\u003e result2.GetComponent\u003cMeshRenderer\u003e().material = result1))));\n```\n\n### Lifetime managment\n\nWhen you load an addressable asset, you should release it as soon as you don't need it anymore, forgetting to do this can lead to many bad processes at runtime. Using the `Addressables Master` you can bind a release to the `GameoObject` that will do it for you automatically as soon as it is destroyed.\n\nThe `Addressables Master` has two ways to manage the release of objects, the first is to use [methods of extending the basic operations](#addressables-extensions) of the Addressables, the second is to use separate methods of life management.\n\n#### Addressables Extensions\n\nIf you need to use standard operations for working with addressables assets, then you can use the extensions.\n\n```c#\npublic static async Task\u003cAsyncOperationHandle\u003cT\u003e\u003e AddAutoRelease\u003cT\u003e(this AsyncOperationHandle\u003cT\u003e operationHandle, GameObject targetGO)\n```\n\n```c#\npublic static async Task\u003cAsyncOperationHandle\u003cT\u003e\u003e AddAutoRelease\u003cT\u003e(this AsyncOperationHandle\u003cT\u003e operationHandle, GameObject targetGO, Action onCompletion)\n```\n\n```c#\npublic static async Task\u003cAsyncOperationHandle\u003cGameObject\u003e\u003e AddReleaseOnDestroy(this AsyncOperationHandle\u003cGameObject\u003e operationHandle)\n```\n\nExamples:\n\n```c#\nGameObject go = new GameObject(\"Temp\");\n\nassetReferenceMaterial.LoadAssetAsync().AddAutoRelease(go);\n\nfigureAssetRefGO.InstantiateAsync().AddReleaseOnDestroy();\n```\n\n#### Management operations\n\n`Sync`\n\n```c#\npublic static GameObject InstantiateSyncWithAutoRelease(string key, Transform parent = null,\n            bool inWorldSpace = false)\n```\n\n```c#\npublic static GameObject InstantiateSyncWithAutoRelease(AssetReference assetReference, Transform parent = null,\n            bool inWorldSpace = false)\n```\n\n`Async .NET`\n\n```c#\npublic static async Task\u003cGameObject\u003e InstantiateAsyncWithAutoRelease(string key, Transform parent = null,\n            bool inWorldSpace = false, Action\u003cGameObject\u003e onCompletion = null)\n```\n\n```c#\npublic static async Task\u003cGameObject\u003e InstantiateAsyncWithAutoRelease(AssetReference assetReference, Transform parent = null, bool inWorldSpace = false)\n```\n\n`Async UniTask`\n\n```c#\npublic static async UniTask\u003cGameObject\u003e InstantiateAsyncWithAutoRelease(string key, Transform parent = null,\n            bool inWorldSpace = false, Action\u003cGameObject\u003e onCompletion = null)\n```\n\n```c#\npublic static async UniTask\u003cGameObject\u003e InstantiateAsyncWithAutoRelease(AssetReference assetReference,\n            Transform parent = null, bool inWorldSpace = false, Action\u003cGameObject\u003e onCompletion = null)\n```\n\n`Coroutine`\n\n```c#\npublic static IEnumerator InstantiateWithAutoReleaseCoroutine(string key, Transform parent = null,\n            bool inWorldSpace = false, bool trackHandle = true, Action\u003cstring, GameObject\u003e onSucceeded = null,\n            Action\u003cstring\u003e onFailed = null)\n```\n\n```c#\npublic static IEnumerator InstantiateWithAutoReleaseCoroutine(AssetReference reference, Transform parent = null,\n            bool inWorldSpace = false, Action\u003cstring, GameObject\u003e onSucceeded = null, Action\u003cstring\u003e onFailed = null)\n```\n\n`Methods not tied to a specific management model`\n\n```c#\npublic static void AddAutoReleaseAssetTrigger(string key, GameObject targetGO)\n```\n\n```c#\npublic static void AddAutoReleaseAssetTrigger(AssetReference assetReference, GameObject targetGO)\n```\n\n```c#\npublic static void AddAutoReleaseInstanceTrigger(string key, GameObject targetGO)\n```\n\n```c#\npublic static void AddAutoReleaseInstanceTrigger(AssetReference assetReference, GameObject targetGO)\n```\n\n#### Short examples\n\n```c#\nManageAddressables.InstantiateSyncWithAutoRelease(figureAssetRefGO);\nManageAddressables.InstantiateAsyncWithAutoRelease(figureAssetRefGO, onCompletion: x =\u003e x.transform.position = Vector3.up);\n\n// or\n\nvar material = ManageAddressables.LoadAssetAsync(assetReferenceMaterial).Result.Value;\nGameObject tempGO = new GameObject(\"Temp\");\nManageAddressables.AddAutoReleaseAssetTrigger(assetReferenceMaterial, tempGO); // assetReferenceMaterial will be released as soon as tempGO is destroyed\n```\n\n## Credits\n\nThe project is based on a [Laicasaane](https://github.com/laicasaane) solution named [Unity Addressables Manager](https://github.com/laicasaane/unity-addressables-manager).\n\nLogo background by founder of [Kvistholt Photography](https://unsplash.com/@freeche).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finc8877%2FAddressablesMaster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finc8877%2FAddressablesMaster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finc8877%2FAddressablesMaster/lists"}