{"id":22486,"date":"2026-10-18T10:26:15","date_gmt":"2026-10-18T01:26:15","guid":{"rendered":"https:\/\/cg-method.com\/unity\/?p=22486"},"modified":"2026-10-18T10:26:15","modified_gmt":"2026-10-18T01:26:15","slug":"unity-object-pool","status":"publish","type":"post","link":"https:\/\/cg-method.com\/unity\/unity-object-pool\/","title":{"rendered":"Unity\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30d7\u30fc\u30eb\u306e\u4f7f\u3044\u65b9\uff5c\u751f\u6210\u30fb\u518d\u5229\u7528\u30fb\u8fd4\u5374\u306e\u57fa\u672c"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Unity\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30d7\u30fc\u30eb\u306f\u3001\u5f3e\u3084\u30a8\u30d5\u30a7\u30af\u30c8\u306e\u3088\u3046\u306b\u4f55\u5ea6\u3082\u51fa\u3057\u5165\u308c\u3059\u308b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u3001\u6bce\u56de\u4f5c\u3063\u3066\u6d88\u3059\u306e\u3067\u306f\u306a\u304f\u3001\u4f7f\u3044\u7d42\u308f\u3063\u305f\u3089\u53d6\u3063\u3066\u304a\u3044\u3066\u4f7f\u3044\u56de\u3059\u4ed5\u7d44\u307f\u3067\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Unity\u306b\u306f\u3001\u305d\u306e\u305f\u3081\u306e ObjectPool&lt;T&gt; \u3068\u3044\u3046\u30af\u30e9\u30b9\u304c UnityEngine.Pool \u306b\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n\n<li>\u53d6\u308a\u51fa\u3059\uff1apool.Get()\uff08\u7a7a\u306a\u3089\u65b0\u3057\u304f\u4f5c\u308b\uff09<\/li>\n\n\n<li>\u8fd4\u3059\uff1apool.Release(\u30aa\u30d6\u30b8\u30a7\u30af\u30c8)\uff08Destroy\u306e\u4ee3\u308f\u308a\u306b\u547c\u3076\uff09<\/li>\n\n\n<li>\u4f5c\u308a\u65b9\u30fb\u53d6\u308a\u51fa\u3057\u6642\u30fb\u8fd4\u5374\u6642\u30fb\u7834\u68c4\u6642\u306e\u51e6\u7406\u3092\u3001\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u30fc\u306b\u95a2\u6570\u3067\u6e21\u3059<\/li>\n\n\n<li>\u591a\u304f\u306e\u5834\u5408\u3001\u53d6\u308a\u51fa\u3059\u3068\u304d\u306bSetActive(true)\u3001\u8fd4\u3059\u3068\u304d\u306bSetActive(false)\u306b\u3059\u308b<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u3053\u306e\u8a18\u4e8b\u306f\u3001Unity 6.3 LTS\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u3068\u516c\u5f0f\u30de\u30cb\u30e5\u30a2\u30eb\u300cPooling and reusing objects\u300d\u306e\u8a18\u8f09\uff082026\u5e7410\u670818\u65e5\u306b\u78ba\u8a8d\uff09\u306b\u57fa\u3065\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Unity\u306e\u30a8\u30c7\u30a3\u30bf\u3067\u306e\u5b9f\u6a5f\u3067\u306e\u518d\u73fe\u306f\u542b\u307e\u305a\u3001\u63b2\u8f09\u3057\u305f\u30b3\u30fc\u30c9\u3082Unity\u3067\u306e\u5b9f\u884c\u306f\u78ba\u304b\u3081\u3066\u3044\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30d7\u30fc\u30eb\u3092\u4f7f\u3046\u7406\u7531<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u516c\u5f0f\u30de\u30cb\u30e5\u30a2\u30eb\u3067\u306f\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30d7\u30fc\u30eb\u306f\u3001\u4f5c\u6210\u3068\u7834\u68c4\u3092\u304f\u308a\u8fd4\u3059\u3053\u3068\u306b\u3088\u308b\u8ca0\u8377\u3092\u6e1b\u3089\u3057\u3001\u30e1\u30e2\u30ea\u306e\u78ba\u4fdd\u3068\u89e3\u653e\u306e\u56de\u6570\u3092\u6291\u3048\u308b\u3068\u8aac\u660e\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u305d\u306e\u7d50\u679c\u3001\u30ac\u30d9\u30fc\u30b8\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u8ca0\u8377\u3068CPU\u306e\u8ca0\u8377\u304c\u4e0b\u304c\u308b\u3068\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u30de\u30cb\u30e5\u30a2\u30eb\u3067\u306f\u3001\u5f3e\u306e\u3088\u3046\u306b\u4f55\u5ea6\u3082\u51fa\u3066\u304f\u308b\u304c\u3001\u540c\u6642\u306b\u753b\u9762\u306b\u3042\u308b\u306e\u306f\u5c11\u3057\u3060\u3051\u3001\u3068\u3044\u3046\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u4f8b\u306b\u6319\u304c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6483\u3064\u305f\u3073\u306bPrefab\u304b\u3089Instantiate\u3059\u308b\u306e\u3067\u306f\u306a\u304f\u3001\u6700\u521d\u306b\u30d7\u30fc\u30eb\u3092\u4f5c\u3063\u3066\u304a\u304d\u3001\u5fc5\u8981\u306a\u3068\u304d\u306b\u53d6\u308a\u51fa\u3057\u3066\u4f7f\u3044\u56de\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">ObjectPool\u306e\u4f5c\u308a\u65b9<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">ObjectPool&lt;T&gt; \u306f\u3001\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u30fc\u306b\u6b21\u306e\u5024\u3092\u6e21\u3057\u3066\u4f5c\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-regular\"><table class=\"has-fixed-layout\"><thead><tr><th style=\"min-width:8em !important\">\u5f15\u6570<\/th><th>\u5f79\u5272<\/th><\/tr><\/thead><tbody><tr><td>createFunc<\/td><td>\u30d7\u30fc\u30eb\u304c\u7a7a\u306e\u3068\u304d\u306b\u3001\u65b0\u3057\u3044\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u308b\u95a2\u6570<\/td><\/tr><tr><td>actionOnGet<\/td><td>\u30d7\u30fc\u30eb\u304b\u3089\u53d6\u308a\u51fa\u3057\u305f\u3068\u304d\u306b\u547c\u3070\u308c\u308b\u3002\u6e96\u5099\u3092\u3057\u3066\u6709\u52b9\u306b\u3059\u308b<\/td><\/tr><tr><td>actionOnRelease<\/td><td>\u30d7\u30fc\u30eb\u306b\u8fd4\u3057\u305f\u3068\u304d\u306b\u547c\u3070\u308c\u308b\u3002\u5f8c\u7247\u4ed8\u3051\u3092\u3057\u3066\u7121\u52b9\u306b\u3059\u308b<\/td><\/tr><tr><td>actionOnDestroy<\/td><td>\u30d7\u30fc\u30eb\u304c\u6700\u5927\u6570\u306b\u9054\u3057\u3066\u3044\u3066\u8fd4\u305b\u306a\u3044\u3068\u304d\u306b\u547c\u3070\u308c\u308b\u3002\u3053\u3053\u3067\u7834\u68c4\u3059\u308b<\/td><\/tr><tr><td>collectionCheck<\/td><td>true\u306b\u3059\u308b\u3068\u3001\u65e2\u306b\u30d7\u30fc\u30eb\u306b\u3042\u308b\u7269\u3092\u3082\u3046\u4e00\u5ea6\u8fd4\u3057\u305f\u3068\u304d\u306b\u4f8b\u5916\u3092\u51fa\u3059<\/td><\/tr><tr><td>defaultCapacity<\/td><td>\u6700\u521d\u306b\u7528\u610f\u3059\u308b\u5165\u308c\u7269\u306e\u5927\u304d\u3055<\/td><\/tr><tr><td>maxSize<\/td><td>\u30d7\u30fc\u30eb\u306b\u7f6e\u3044\u3066\u304a\u3051\u308b\u6700\u5927\u306e\u6570<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">Unity 6.3 LTS\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u300cObjectPool&lt;T&gt; \u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u30fc\u300d\u3092\u3082\u3068\u306b\u4f5c\u6210<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u30b9\u30af\u30ea\u30d7\u30c8\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u3067\u306f\u3001defaultCapacity\u306e\u6570\u3060\u3051\u6700\u521d\u306b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u4f5c\u3089\u308c\u308b\u308f\u3051\u3067\u306f\u306a\u304f\u3001Get\u3092\u547c\u3093\u3060\u3068\u304d\u306b1\u3064\u305a\u3064\u4f5c\u3089\u308c\u308b\u3068\u8aac\u660e\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">maxSize\u306b\u9054\u3057\u305f\u5f8c\u306b\u8fd4\u3055\u308c\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f\u30d7\u30fc\u30eb\u306b\u5165\u3089\u305a\u3001actionOnDestroy\u3067\u7834\u68c4\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">collectionCheck\u306b\u3088\u308b\u691c\u51fa\u306f\u30a8\u30c7\u30a3\u30bf\u306e\u4e2d\u3060\u3051\u3067\u884c\u308f\u308c\u3001\u30d3\u30eb\u30c9\u3057\u305f\u30a2\u30d7\u30ea\u3067\u306f\u884c\u308f\u308c\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u516c\u5f0f\u30de\u30cb\u30e5\u30a2\u30eb\u3067\u306f\u3001\u691c\u51fa\u306e\u305f\u3081\u306e\u8ca0\u8377\u306f\u3042\u308b\u3082\u306e\u306e\u3001\u958b\u767a\u4e2d\u306ftrue\u306b\u3057\u3066\u304a\u304f\u3053\u3068\u304c\u52e7\u3081\u3089\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5f3e\u3092\u4f7f\u3044\u56de\u3059\u4f8b<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u6b21\u306e\u4f8b\u306f\u3001\u4e00\u5b9a\u306e\u9593\u9694\u3067\u5f3e\u3092\u51fa\u3057\u30012\u79d2\u305f\u3063\u305f\u3089\u30d7\u30fc\u30eb\u306b\u8fd4\u3059\u3082\u306e\u3067\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u516c\u5f0f\u30de\u30cb\u30e5\u30a2\u30eb\u306e\u5f3e\u306e\u4f8b\u3068\u540c\u3058\u304f\u3001\u5f3e\u306b\u81ea\u5206\u306e\u30d7\u30fc\u30eb\u3092\u6301\u305f\u305b\u3001\u5f3e\u304c\u81ea\u5206\u3067\u8fd4\u308b\u5f62\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5f3e\u306e\u30b9\u30af\u30ea\u30d7\u30c8<\/h3>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-csharp\"><code>using UnityEngine;\nusing UnityEngine.Pool;\n\npublic class Bullet : MonoBehaviour\n{\n    [SerializeField] float speed = 10f;\n    [SerializeField] float lifeTime = 2f;\n\n    IObjectPool&lt;Bullet&gt; pool;\n    float timer;\n\n    \/\/ \u3069\u306e\u30d7\u30fc\u30eb\u306b\u8fd4\u3059\u304b\u3092\u3001\u4f5c\u3063\u305f\u3068\u304d\u306b\u53d7\u3051\u53d6\u308b\n    public void SetPool(IObjectPool&lt;Bullet&gt; owner)\n    {\n        pool = owner;\n    }\n\n    \/\/ \u53d6\u308a\u51fa\u3059\u305f\u3073\u306b\u3001\u4f4d\u7f6e\u3068\u7d4c\u904e\u6642\u9593\u3092\u521d\u3081\u306e\u72b6\u614b\u306b\u623b\u3059\n    public void ResetState(Vector3 position, Quaternion rotation)\n    {\n        transform.SetPositionAndRotation(position, rotation);\n        timer = 0f;\n    }\n\n    void Update()\n    {\n        transform.Translate(Vector3.forward * speed * Time.deltaTime);\n        timer += Time.deltaTime;\n        if (timer &gt;= lifeTime)\n        {\n            pool.Release(this); \/\/ Destroy\u306e\u4ee3\u308f\u308a\u306b\u30d7\u30fc\u30eb\u3078\u8fd4\u3059\n        }\n    }\n}<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">\u5f3e\u3092\u51fa\u3059\u30b9\u30af\u30ea\u30d7\u30c8<\/h3>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-csharp\"><code>using UnityEngine;\nusing UnityEngine.Pool;\n\npublic class BulletSpawner : MonoBehaviour\n{\n    [SerializeField] Bullet bulletPrefab;\n    [SerializeField] float interval = 0.2f;\n\n    ObjectPool&lt;Bullet&gt; pool;\n    float nextTime;\n\n    void Awake()\n    {\n        pool = new ObjectPool&lt;Bullet&gt;(\n            createFunc: () =&gt;\n            {\n                var bullet = Instantiate(bulletPrefab);\n                bullet.SetPool(pool);\n                return bullet;\n            },\n            actionOnGet: bullet =&gt; bullet.gameObject.SetActive(true),\n            actionOnRelease: bullet =&gt; bullet.gameObject.SetActive(false),\n            actionOnDestroy: bullet =&gt; Destroy(bullet.gameObject),\n            collectionCheck: true,\n            defaultCapacity: 20,\n            maxSize: 100);\n    }\n\n    void Update()\n    {\n        if (Time.time &lt; nextTime) return;\n        nextTime = Time.time + interval;\n\n        var bullet = pool.Get();\n        bullet.ResetState(transform.position, transform.rotation);\n    }\n}<\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">BulletSpawner\u3092\u7a7a\u306e\u30b2\u30fc\u30e0\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u4ed8\u3051\u3001Bullet\u3092\u4ed8\u3051\u305fPrefab\u3092 Bullet Prefab \u306e\u6b04\u306b\u5165\u308c\u3066\u518d\u751f\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u3053\u306e\u30b3\u30fc\u30c9\u306f\u3001\u30b9\u30af\u30ea\u30d7\u30c8\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u3068\u516c\u5f0f\u30de\u30cb\u30e5\u30a2\u30eb\u306e\u4f8b\u3092\u3082\u3068\u306b\u66f8\u3044\u305f\u3082\u306e\u3067\u3001Unity\u3067\u306e\u5b9f\u884c\u306f\u78ba\u304b\u3081\u3066\u3044\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8fd4\u3059\u3068\u304d\u306b\u72b6\u614b\u3092\u623b\u3059<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u30d7\u30fc\u30eb\u304b\u3089\u53d6\u308a\u51fa\u3057\u305f\u7269\u306f\u3001\u524d\u306b\u4f7f\u3063\u305f\u3068\u304d\u306e\u4f4d\u7f6e\u3084\u901f\u5ea6\u306a\u3069\u304c\u6b8b\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u516c\u5f0f\u30de\u30cb\u30e5\u30a2\u30eb\u3067\u306f\u3001\u6b21\u306b\u53d6\u308a\u51fa\u3057\u305f\u3068\u304d\u306b\u521d\u3081\u3066\u4f7f\u3046\u3068\u304d\u3068\u540c\u3058\u72b6\u614b\u304b\u3089\u59cb\u307e\u308b\u3088\u3046\u306b\u3001\u72b6\u614b\u3092\u623b\u3059\u3053\u3068\u304c\u5927\u5207\u3060\u3068\u8aac\u660e\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u623b\u3059\u5834\u6240\u306f\u3001actionOnGet\u3067\u3082actionOnRelease\u3067\u3082\u3088\u304f\u3001\u30d7\u30fc\u30eb\u3055\u308c\u308b\u5074\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u5c02\u7528\u306e\u95a2\u6570\u3092\u4f5c\u3063\u3066\u547c\u3076\u65b9\u6cd5\u3082\u6319\u304c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd4\u3059\u3068\u304d\u306b\u3088\u304f\u884c\u3046\u5f8c\u7247\u4ed8\u3051\u3068\u3057\u3066\u3001\u30de\u30cb\u30e5\u30a2\u30eb\u3067\u306f\u6b21\u306e\u3082\u306e\u304c\u6319\u304c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n\n<li>\u30b3\u30eb\u30fc\u30c1\u30f3\u3092\u6b62\u3081\u308b<\/li>\n\n\n<li>\u30a4\u30d9\u30f3\u30c8\u306e\u767b\u9332\u3092\u5916\u3059<\/li>\n\n\n<li>Rigidbody\u306e\u901f\u5ea6\u306a\u3069\u306e\u7269\u7406\u306e\u72b6\u614b\u3092\u623b\u3059<\/li>\n\n\n<li>\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u521d\u3081\u306e\u72b6\u614b\u306b\u623b\u3059<\/li>\n\n\n<li>\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u30b7\u30b9\u30c6\u30e0\u3092\u6b62\u3081\u308b<\/li>\n\n\n<li>\u30b2\u30fc\u30e0\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u7121\u52b9\u306b\u3057\u3066\u3001\u30d7\u30fc\u30eb\u306e\u4e2d\u3067Update\u304c\u547c\u3070\u308c\u306a\u3044\u3088\u3046\u306b\u3059\u308b<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u516c\u5f0f\u30de\u30cb\u30e5\u30a2\u30eb\u306e\u5f3e\u306e\u4f8b\u3067\u306f\u3001\u8fd4\u3059\u524d\u306bRigidbody\u306e linearVelocity \u3068 angularVelocity \u30920\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u3088\u304f\u3042\u308b\u9593\u9055\u3044<\/h2>\n\n\n\n<figure class=\"wp-block-table is-style-regular\"><table class=\"has-fixed-layout\"><thead><tr><th style=\"min-width:8em !important\">\u9593\u9055\u3044<\/th><th>\u8d77\u304d\u308b\u3053\u3068\u30fb\u76f4\u3057\u65b9<\/th><\/tr><\/thead><tbody><tr><td>\u8fd4\u3059\u3068\u304d\u306bDestroy\u3057\u3066\u3044\u308b<\/td><td>\u4f7f\u3044\u56de\u305b\u305a\u3001\u6bce\u56de\u4f5c\u308a\u76f4\u3057\u306b\u306a\u308b\u3002Destroy\u306e\u4ee3\u308f\u308a\u306bRelease\u3092\u547c\u3076<\/td><\/tr><tr><td>\u540c\u3058\u7269\u30922\u56deRelease\u3057\u3066\u3044\u308b<\/td><td>collectionCheck\u304ctrue\u306a\u3089\u3001\u30a8\u30c7\u30a3\u30bf\u3067\u4f8b\u5916\u304c\u51fa\u308b\u3002\u8fd4\u3057\u305f\u5f8c\u306f\u305d\u306e\u7269\u3092\u4f7f\u308f\u306a\u3044<\/td><\/tr><tr><td>\u53d6\u308a\u51fa\u3057\u305f\u7269\u306e\u72b6\u614b\u3092\u623b\u3057\u3066\u3044\u306a\u3044<\/td><td>\u524d\u306b\u4f7f\u3063\u305f\u3068\u304d\u306e\u4f4d\u7f6e\u3084\u901f\u5ea6\u306e\u307e\u307e\u52d5\u304d\u51fa\u3059<\/td><\/tr><tr><td>\u8fd4\u3059\u3068\u304d\u306b\u7121\u52b9\u306b\u3057\u3066\u3044\u306a\u3044<\/td><td>\u30d7\u30fc\u30eb\u306e\u4e2d\u3067\u3082Update\u304c\u547c\u3070\u308c\u7d9a\u3051\u308b<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">\u516c\u5f0f\u30de\u30cb\u30e5\u30a2\u30eb\u300cPooling and reusing objects\u300d\u3068\u30b9\u30af\u30ea\u30d7\u30c8\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u3092\u3082\u3068\u306b\u7de8\u96c6\u90e8\u3067\u6574\u7406<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u30d7\u30fc\u30eb\u306e\u72b6\u614b\u306f\u3001CountActive\uff08\u4f7f\u7528\u4e2d\u306e\u6570\uff09\u3001CountInactive\uff08\u30d7\u30fc\u30eb\u3067\u5f85\u3063\u3066\u3044\u308b\u6570\uff09\u3001CountAll\uff08\u5408\u8a08\uff09\u3067\u78ba\u304b\u3081\u3089\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6570\u304c\u5897\u3048\u7d9a\u3051\u308b\u5834\u5408\u306f\u3001Release\u3092\u547c\u3073\u5fd8\u308c\u3066\u3044\u308b\u7269\u304c\u306a\u3044\u304b\u3092\u898b\u76f4\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30b7\u30fc\u30f3\u3092\u5207\u308a\u66ff\u3048\u308b\u3068\u304d\u306e\u6ce8\u610f<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u516c\u5f0f\u30de\u30cb\u30e5\u30a2\u30eb\u3067\u306f\u3001\u30d7\u30fc\u30eb\u306f\u4f5c\u3089\u308c\u305f\u30b7\u30fc\u30f3\u306b\u7d50\u3073\u4ed8\u3044\u3066\u3044\u3066\u3001\u305d\u306e\u30b7\u30fc\u30f3\u304c\u7834\u68c4\u3055\u308c\u308b\u3068\u3001\u30d7\u30fc\u30eb\u3068\u30d7\u30fc\u30eb\u306e\u4e2d\u306e\u7269\u3082\u307e\u3068\u3081\u3066\u7834\u68c4\u3055\u308c\u308b\u3068\u8aac\u660e\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u30b7\u30fc\u30f3\u3092\u307e\u305f\u3044\u3067\u30d7\u30fc\u30eb\u3092\u6b8b\u3059\u5834\u5408\u306f\u3001\u30d7\u30fc\u30eb\u3092\u7ba1\u7406\u3059\u308b\u30b2\u30fc\u30e0\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306bDontDestroyOnLoad\u3092\u4f7f\u3044\u3001\u8fd4\u3059\u3068\u304d\u306bSetParent\u3067\u305d\u306e\u4e0b\u3078\u623b\u3059\u65b9\u6cd5\u304c\u6848\u5185\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u30b7\u30fc\u30f3\u3092\u7834\u68c4\u3059\u308b\u3068\u304d\u306b\u4f7f\u7528\u4e2d\u306e\u7269\u304c\u3042\u308b\u5834\u5408\u306f\u3001OnDisable\u3084OnDestroy\u3067\u81ea\u5206\u3092\u8fd4\u3059\u3088\u3046\u306b\u3059\u308b\u304b\u3001SceneManager.activeSceneChanged\u3067\u56de\u53ce\u3059\u308b\u3088\u3046\u52e7\u3081\u3089\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u30b9\u30c6\u30fc\u30b8\u306e\u5207\u308a\u66ff\u3048\u306a\u3069\u3067\u5f85\u3063\u3066\u3044\u308b\u7269\u3092\u307e\u3068\u3081\u3066\u7834\u68c4\u3057\u305f\u3044\u3068\u304d\u306f\u3001Clear\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u30b7\u30fc\u30f3\u306e\u8aad\u307f\u8fbc\u307f\u65b9\u306f\u3001<a href=\"https:\/\/cg-method.com\/unity\/multiple-scene-load\/\">Unity\u3067\u30b7\u30fc\u30f3\u3092\u5207\u308a\u66ff\u3048\u308b\u65b9\u6cd5<\/a>\u3067\u8aac\u660e\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30b2\u30fc\u30e0\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u4ee5\u5916\u3082\u30d7\u30fc\u30eb\u3067\u304d\u308b<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u516c\u5f0f\u30de\u30cb\u30e5\u30a2\u30eb\u3067\u306f\u3001List\u3084Dictionary\u306e\u3088\u3046\u306a\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3082\u3001\u30d7\u30fc\u30eb\u3057\u3066\u4f7f\u3044\u56de\u305b\u308b\u3068\u8aac\u660e\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">UnityEngine.Pool\u306b\u306f\u3001List&lt;T&gt;\u3001HashSet&lt;T&gt;\u3001Dictionary&lt;TKey, TValue&gt;\u306e\u305f\u3081\u306e\u30d7\u30fc\u30eb\u3082\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6bce\u30d5\u30ec\u30fc\u30e0 new List&lt;T&gt;() \u3092\u3057\u3066\u3044\u308b\u51e6\u7406\u306f\u3001\u30af\u30e9\u30b9\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u306b1\u3064\u6301\u3063\u3066Clear\u3067\u4f7f\u3044\u56de\u3059\u3060\u3051\u3067\u3082\u3001\u30e1\u30e2\u30ea\u306e\u78ba\u4fdd\u3092\u6e1b\u3089\u305b\u308b\u3068\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u30de\u30cb\u30e5\u30a2\u30eb\u3067\u306f\u3001UnityEngine.Pool\u306e\u6a5f\u80fd\u306f\u30b9\u30ec\u30c3\u30c9\u30bb\u30fc\u30d5\u3067\u306f\u306a\u304f\u3001\u30e1\u30a4\u30f3\u30b9\u30ec\u30c3\u30c9\u304b\u3089\u547c\u3076\u5fc5\u8981\u304c\u3042\u308b\u3068\u6ce8\u610f\u66f8\u304d\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u53c2\u8003\u306b\u3057\u305f\u516c\u5f0f\u30da\u30fc\u30b8<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n\n<li><a href=\"https:\/\/docs.unity3d.com\/6000.3\/Documentation\/Manual\/performance-reusable-code.html\">Pooling and reusing objects<\/a><\/li>\n\n\n<li><a href=\"https:\/\/docs.unity3d.com\/6000.3\/Documentation\/ScriptReference\/Pool.ObjectPool_1.html\">ObjectPool&lt;T&gt;\uff08\u30b9\u30af\u30ea\u30d7\u30c8\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\uff09<\/a><\/li>\n\n\n<li><a href=\"https:\/\/docs.unity3d.com\/6000.3\/Documentation\/ScriptReference\/Pool.ObjectPool_1-ctor.html\">ObjectPool&lt;T&gt; \u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u30fc\uff08\u30b9\u30af\u30ea\u30d7\u30c8\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\uff09<\/a><\/li>\n\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Unity\u306eObjectPool\u3067\u3001\u3088\u304f\u51fa\u3057\u5165\u308c\u3059\u308b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f7f\u3044\u56de\u3059\u65b9\u6cd5\u3092\u3001Get\u3068Release\u3001\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u3001\u5bb9\u91cf\u306e\u8a2d\u5b9a\u3001\u30b7\u30fc\u30f3\u5207\u308a\u66ff\u3048\u6642\u306e\u6ce8\u610f\u307e\u3067\u516c\u5f0f\u8cc7\u6599\u306b\u6cbf\u3063\u3066\u6574\u7406\u3057\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"author":1,"featured_media":22487,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","book_review_data":"","footnotes":"","ssp_meta_title":"Unity\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30d7\u30fc\u30eb\u306e\u4f7f\u3044\u65b9\uff5cObjectPool","ssp_meta_description":"Unity\u306eObjectPool\u3067\u3001\u5f3e\u306a\u3069\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u751f\u6210\u30fb\u518d\u5229\u7528\u30fb\u8fd4\u5374\u3059\u308b\u57fa\u672c\u3092\u30b3\u30fc\u30c9\u4ed8\u304d\u3067\u89e3\u8aac\u3002Get\u3068Release\u30014\u3064\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u3001defaultCapacity\u3068maxSize\u3001\u4e8c\u91cd\u8fd4\u5374\u306e\u691c\u51fa\u3001\u30b7\u30fc\u30f3\u5207\u308a\u66ff\u3048\u6642\u306e\u6ce8\u610f\u3082\u3002"},"categories":[25],"tags":[],"class_list":["post-22486","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting"],"_links":{"self":[{"href":"https:\/\/cg-method.com\/unity\/wp-json\/wp\/v2\/posts\/22486","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cg-method.com\/unity\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cg-method.com\/unity\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cg-method.com\/unity\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cg-method.com\/unity\/wp-json\/wp\/v2\/comments?post=22486"}],"version-history":[{"count":1,"href":"https:\/\/cg-method.com\/unity\/wp-json\/wp\/v2\/posts\/22486\/revisions"}],"predecessor-version":[{"id":22488,"href":"https:\/\/cg-method.com\/unity\/wp-json\/wp\/v2\/posts\/22486\/revisions\/22488"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cg-method.com\/unity\/wp-json\/wp\/v2\/media\/22487"}],"wp:attachment":[{"href":"https:\/\/cg-method.com\/unity\/wp-json\/wp\/v2\/media?parent=22486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cg-method.com\/unity\/wp-json\/wp\/v2\/categories?post=22486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cg-method.com\/unity\/wp-json\/wp\/v2\/tags?post=22486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}