{"id":18546913,"url":"https://github.com/mr-sb/objectpool","last_synced_at":"2025-04-09T20:31:08.143Z","repository":{"id":113700026,"uuid":"256140191","full_name":"Mr-sB/ObjectPool","owner":"Mr-sB","description":"The Unity object pooling can load and cache all objects inherited from UnityEngine.Object, and can easily expand the loading method, such as loading objects from AssetBundle. And contains CommonPool to cache other type objects.","archived":false,"fork":false,"pushed_at":"2024-08-28T04:54:19.000Z","size":39,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T11:12:40.666Z","etag":null,"topics":["cache","objectpool","script","unity"],"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/Mr-sB.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":"2020-04-16T07:23:04.000Z","updated_at":"2025-02-04T07:50:52.000Z","dependencies_parsed_at":"2024-11-06T20:33:14.692Z","dependency_job_id":"e078b293-0f1b-4764-9cbd-9b0fcbe62c47","html_url":"https://github.com/Mr-sB/ObjectPool","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/Mr-sB%2FObjectPool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mr-sB%2FObjectPool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mr-sB%2FObjectPool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mr-sB%2FObjectPool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mr-sB","download_url":"https://codeload.github.com/Mr-sB/ObjectPool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248107260,"owners_count":21048887,"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":["cache","objectpool","script","unity"],"created_at":"2024-11-06T20:27:31.392Z","updated_at":"2025-04-09T20:31:07.803Z","avatar_url":"https://github.com/Mr-sB.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ObjectPool\nThe Unity object pooling can load and cache all objects inherited from UnityEngine.Object, and can easily expand the loading method, such as loading objects from AssetBundle. \nAnd contains CommonPool to cache other type objects.\n\n# Feature\n* `ObjectPool` can load and cache all objects inherited from `UnityEngine.Object`.\n* For `CommonPool`, build in ListPool, QueuePool, StackPool, HashSetPool, DictionaryPool to use.\n* Unused assets/objects and `PoolItem` will auto destroy by `DeleteTime`. If `DeleteTime` is -1, they will not auto destroy.\n* `LoadMode.Resource` to cache from Resources folder.\n* `LoadMode.Custom` to cache from anywhere by call `ObjectPool.Instance.RegisterCustomPoolItem` function first.\n* If you cache `GameObject`, you can implement `ISpawnHandler` and `IDisposeHandler` interfaces to listen spawn and dispose actions.\n```c#\npublic interface ISpawnHandler\n{\n    void OnSpawn();\n}\npublic interface IDisposeHandler\n{\n    void OnDispose();\n}\n```\nOr you can add listener from `ObjectPoolItemKey.SpawnEvent` and `ObjectPoolItemKey.DisposeEvent`.\n```c#\npublic event Action\u003cObjectPoolItemKey\u003e SpawnEvent;\npublic event Action\u003cObjectPoolItemKey\u003e DisposeEvent;\n```\n* Basically does not consume extra memory and GC.\n\n# Note\n* If you want to cache Object from `AssetBundle`, maybe you can use [AssetBundleManager](https://github.com/Mr-sB/AssetBundleManager)(Open source) to manage your AssetBundles.\n```c#\npublic ObjectPoolItem(Type assetType, ObjectPool.LoadMode loadMode, string bundleName, string assetName, DeleteTime deleteTime) : base(deleteTime)\n{\n    ...\n    switch (mLoadMode)\n    {\n        case ObjectPool.LoadMode.Resource:\n            OriginAsset = Resources.Load(assetName, assetType);\n            break;\n        case ObjectPool.LoadMode.Custom:\n            break;\n        // MARK: Use AssetBundleManager to load asset.\n        case ObjectPool.LoadMode.AssetBundle:\n            OriginAsset = AssetBundleManager.GetAsset(assetType, bundleName, assetName);\n            break;\n        // MARK: Add yourself load methods\n    }\n    ...\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmr-sb%2Fobjectpool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmr-sb%2Fobjectpool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmr-sb%2Fobjectpool/lists"}