Title: Instantiate a custom amount of objects on startup to save even more performance by alfredbaudisch · Pull Request #1 · UnityPatterns/ObjectPool · GitHub
Open Graph Title: Instantiate a custom amount of objects on startup to save even more performance by alfredbaudisch · Pull Request #1 · UnityPatterns/ObjectPool
X Title: Instantiate a custom amount of objects on startup to save even more performance by alfredbaudisch · Pull Request #1 · UnityPatterns/ObjectPool
Description: With the actual code, if you have a fire rate that allows you to shoot let's say 100 bullets at a time, it will instantiate 100 game objects at runtime for the first shoots. Now if you have different pools running at once like bullets, explosions, coins, power ups, etc (like I have in my game, 7 pools) think about instantiating all these objects when the game is running the first time we need the objects, there is a noticeable frame rate and performance drop during the gameplay, specially in fast paced games. For that reason I improved the class to allow the pre-instantiation of a defined amount of objects at startup. For the Turrent demo, on startup 10 bullets and 10 explosions are added to the pool and recycled before we even need them, this way when we shoot, the pool will never create another object, since 10 is more than enough to the demo's fire rate. The magic is in the new CreatePool(T prefab, int initialAmount) and RecycleAll(T obj) methods. EDITED: CreatePool(T prefab, int initialAmount) now uses SpawnInactive instead of Spawn + RecycleAll.
Open Graph Description: With the actual code, if you have a fire rate that allows you to shoot let's say 100 bullets at a time, it will instantiate 100 game objects at runtime for the first shoots. Now if you have dif...
X Description: With the actual code, if you have a fire rate that allows you to shoot let's say 100 bullets at a time, it will instantiate 100 game objects at runtime for the first shoots. Now if you have...
Opengraph URL: https://github.com/UnityPatterns/ObjectPool/pull/1
X: @github
Domain: patch-diff.githubusercontent.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:863f4d05-bcbf-9ecc-f1e9-019f3cebbdc4 |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | AE0A:134895:11C13C:17A09E:6982716E |
| html-safe-nonce | efe5da70af15dfa883052dfee1d47c02c63ce6f40a0e610b1c05a4dc7b8e9548 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRTBBOjEzNDg5NToxMUMxM0M6MTdBMDlFOjY5ODI3MTZFIiwidmlzaXRvcl9pZCI6Ijc5MjM5NTM3MTc4NTcxMjA2MjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | da2933a9dbcd9f05daadd489decbb3dee656207bfbcd3e67af6b115a4592e1ae |
| hovercard-subject-tag | pull_request:9821162 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/UnityPatterns/ObjectPool/pull/1/checks |
| twitter:image | https://avatars.githubusercontent.com/u/248383?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/248383?s=400&v=4 |
| og:image:alt | With the actual code, if you have a fire rate that allows you to shoot let's say 100 bullets at a time, it will instantiate 100 game objects at runtime for the first shoots. Now if you have dif... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | d8cbbf00e6212b4e561a1d6db613194a319d58a2967494f7cc81cf6da3fbb985 |
| turbo-cache-control | no-preview |
| go-import | github.com/UnityPatterns/ObjectPool git https://github.com/UnityPatterns/ObjectPool.git |
| octolytics-dimension-user_id | 5545416 |
| octolytics-dimension-user_login | UnityPatterns |
| octolytics-dimension-repository_id | 13115287 |
| octolytics-dimension-repository_nwo | UnityPatterns/ObjectPool |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 13115287 |
| octolytics-dimension-repository_network_root_nwo | UnityPatterns/ObjectPool |
| turbo-body-classes | logged-out env-production page-responsive full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 15d777483e72943a892af4ab5c0bbdb20215e6f3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width