{"id":16207716,"url":"https://github.com/mukarillo/unitypooling","last_synced_at":"2025-08-10T20:07:30.956Z","repository":{"id":126316907,"uuid":"134116680","full_name":"Mukarillo/UnityPooling","owner":"Mukarillo","description":" An optimized approach object pooling.","archived":false,"fork":false,"pushed_at":"2019-09-26T06:23:27.000Z","size":4068,"stargazers_count":15,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-25T02:46:02.225Z","etag":null,"topics":["pool-controller","pooling","pooling-utility","unity","unity2d","unity3d-plugin"],"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/Mukarillo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":"mukarillo","tidelift":null,"community_bridge":null,"liberapay":"mukarillo","issuehunt":null,"otechie":null,"custom":null}},"created_at":"2018-05-20T03:29:46.000Z","updated_at":"2024-03-13T08:24:45.000Z","dependencies_parsed_at":"2023-06-16T06:45:19.997Z","dependency_job_id":null,"html_url":"https://github.com/Mukarillo/UnityPooling","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Mukarillo/UnityPooling","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mukarillo%2FUnityPooling","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mukarillo%2FUnityPooling/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mukarillo%2FUnityPooling/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mukarillo%2FUnityPooling/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mukarillo","download_url":"https://codeload.github.com/Mukarillo/UnityPooling/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mukarillo%2FUnityPooling/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269780617,"owners_count":24474686,"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","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["pool-controller","pooling","pooling-utility","unity","unity2d","unity3d-plugin"],"created_at":"2024-10-10T10:14:17.200Z","updated_at":"2025-08-10T20:07:30.926Z","avatar_url":"https://github.com/Mukarillo.png","language":"C#","readme":"# UnityPooling\n An optimized approach object pooling.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/Mukarillo/UnityPooling/blob/master/readmeassets/pooling_example.gif?raw=true\" alt=\"Example\"/\u003e\n\u003c/p\u003e\n\n## How to use\n*you can find a pratical example inside this repository in PoolingScene scene*\n\n### 1 - Create a class that extends `PoolingObject` and, if you wish, implement its virtual members (`OnRelease` and `OnCollect`)\n```c#\npublic class ObjectExample : PoolingObject {\n    private Renderer mRenderer;\n    private MaterialPropertyBlock mPropBlock;\n\n    void Awake()\n    {\n        mPropBlock = new MaterialPropertyBlock();\n        mRenderer = GetComponent\u003cRenderer\u003e();\n    }\n\n    public override void OnCollect()\n    {\n        mRenderer.GetPropertyBlock(mPropBlock);\n        mPropBlock.SetColor(\"_Color\", Random.ColorHSV());\n        mRenderer.SetPropertyBlock(mPropBlock);\n\n        Invoke(\"OnRelease\", 2f);\n\n        base.OnCollect(); \n    }\n}\n```\n### 2 - Create a class to initiate the Pooling\u003cObjectExample\u003e and call `Collect` whenever you need an instance of T\n```c#\npublic class PoolingExample : MonoBehaviour {\n    public GameObject referenceObject;\n\n    private Pooling\u003cObjectExample\u003e mPooling = new Pooling\u003cObjectExample\u003e();\n\n    void Start () {\n        mPooling.Initialize(10, referenceObject, transform);      \n    }\n\n    void Update () {\n        if(Input.GetKeyDown(KeyCode.Space))\n        {\n          var o = mPooling.Collect();\n          o.transform.position = new Vector3(Random.Range(-13f, 13f), Random.Range(-6.5f, 6.5f), 2.66f);\n        }\n    }\n}\n```\n\n## Pooling\u003c T \u003e `public` overview\n### Properties\n|name  |type  |description  |\n|--|--|--|\n|`createMoreIfNeeded` |**bool** |*boolean to control if the system can create more objects if needed. Its true by default.*  |\n|`OnObjectCreationCallBack` |**delegate ObjectCreationCallback** |*callback triggered whenever a new object is created, send T as parameter*  |\n\n### Methods\n\n\u003c/br\u003e\n\n\u003e `pooling.Initialize`\n- *Description*: Initiate the pooling, creating `amount` `objReference` and attaching `T` to the object.\n\n- *Parameters*:\n\n|name  |type  |description  |\n|--|--|--|\n|`amount` |**int** |*initial amount to be created.*  |\n|`refObject` |**GameObject** |*a reference of the object that will be instantiated and handled by the pool.*  |\n|`parent` |**Transform** |*the parent of the instantiated object. set `null` if creating in root.*  |\n|`worldPos` |**Vector3** |*the initial position for instantiated object.*  |\n|`startState` |**int** |*the initial state for instantiated object, if true, it will call OnCollect when instantiating each object, if false, OnRelease*  |\n\n\u003c/br\u003e\n\n\u003e `pooling.Collect`\n- *Description*:\nReturns an instance of `T` object that is not currently being used.\n\n- *Parameters* :\n\n|name  |type  |description  |\n|--|--|--|\n|`parent` |**Transform** |*if you need to change the parent of the object, do it here.*  |\n|`position` |**Vector3** |*position of the object*  |\n|`localPosition` |**bool** |*if true, `position` will be int local space, else, it will be world space.*  |\n\n\u003c/br\u003e\n\n\u003e `dynamicScroll.Release`\n- *Description*: Releases the object.\n\n- *Parameters* :\n\n|name  |type  |description  |\n|--|--|--|\n|`obj` |**T** |*Releases the object.*  |\n\n\u003c/br\u003e\n\n\u003e `dynamicScroll.GetAllWithState`\n- *Description*: Returns a list with objects either being used or not being used.\n\n- *Parameters* :\n\n|name  |type  |description  |\n|--|--|--|\n|`active` |**bool** |*if true, return a `List\u003cT\u003e` of actived objects, else, unused objects.*  |\n\n\n\n\n","funding_links":["https://ko-fi.com/mukarillo","https://liberapay.com/mukarillo"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmukarillo%2Funitypooling","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmukarillo%2Funitypooling","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmukarillo%2Funitypooling/lists"}