{"id":266789,"date":"2024-05-15T16:58:08","date_gmt":"2024-05-15T08:58:08","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/266789.html"},"modified":"2024-05-15T16:58:13","modified_gmt":"2024-05-15T08:58:13","slug":"unity-c-%e4%bb%a3%e7%a0%81-getcomponent-%e6%89%be%e4%b8%8d%e5%88%b0-box%ef%bc%8c%e8%af%a5%e6%80%8e%e4%b9%88%e8%a7%a3%e5%86%b3","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/266789.html","title":{"rendered":"unity C# \u4ee3\u7801 getComponent \u627e\u4e0d\u5230 Box\uff0c\u8be5\u600e\u4e48\u89e3\u51b3"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/27131733\/12bfab61-c6d1-4d5a-9133-70fdbb206faa.webp\" alt=\"unity C# \u4ee3\u7801 getComponent \u627e\u4e0d\u5230 Box\uff0c\u8be5\u600e\u4e48\u89e3\u51b3\" \/><\/p>\n<p><p><strong>\u5728Unity\u4e2d\uff0c\u5982\u679c\u4f7f\u7528<code>GetComponent<\/code>\u627e\u4e0d\u5230Box\u7ec4\u4ef6\uff0c\u53ef\u80fd\u539f\u56e0\u5305\u62ec\u547d\u540d\u9519\u8bef\u3001\u7ec4\u4ef6\u672a\u6dfb\u52a0\u3001\u5c42\u7ea7\u4e0d\u6b63\u786e\u3001\u811a\u672c\u6302\u8f7d\u95ee\u9898\u3001\u6216\u8005Box\u4e0d\u662f\u4e00\u4e2a\u7ec4\u4ef6\u3002<\/strong> \u9996\u5148\uff0c\u5e94\u68c0\u67e5Box\u662f\u5426\u4e3a\u573a\u666f\u4e2d\u7684\u7269\u4f53\u540d\u79f0\uff0c\u786e\u8ba4\u5df2\u6b63\u786e\u6dfb\u52a0\u4e86BoxCollider\u6216\u7c7b\u4f3c\u7684Box\u7c7b\u7ec4\u4ef6\uff0c\u5e76\u4e14\u5b83\u4eec\u4f4d\u4e8e\u5f53\u524d\u811a\u672c\u53ef\u4ee5\u8bbf\u95ee\u7684\u6e38\u620f\u5bf9\u8c61\u4e0a\u3002\u63a5\u4e0b\u6765\u8be6\u7ec6\u63cf\u8ff0\u5982\u4f55\u786e\u8ba4\u7ec4\u4ef6\u662f\u5426\u5df2\u6b63\u786e\u6dfb\u52a0\u5230\u6e38\u620f\u5bf9\u8c61\u4e0a\u3002<\/p>\n<\/p>\n<p><p>\u8981\u89e3\u51b3<code>GetComponent<\/code>\u627e\u4e0d\u5230Box\u7684\u95ee\u9898\uff0c\u53ef\u4ee5\u9996\u5148\u5728Unity\u7f16\u8f91\u5668\u4e2d\u70b9\u51fb\u6e38\u620f\u5bf9\u8c61\uff0c\u7136\u540e\u5728Inspector\u9762\u677f\u91cc\u68c0\u67e5\u662f\u5426\u5b58\u5728BoxCollider\u6216\u4f60\u8981\u67e5\u627e\u7684Box\u578b\u7ec4\u4ef6\u3002\u5982\u679c\u8be5\u7ec4\u4ef6\u5b58\u5728\uff0c\u4f46<code>GetComponent<\/code>\u4ecd\u7136\u627e\u4e0d\u5230\uff0c\u53ef\u80fd\u662f\u56e0\u4e3a\u811a\u672c\u4e0e\u6e38\u620f\u5bf9\u8c61\u4e0d\u5728\u540c\u4e00\u4e2a\u5c42\u7ea7\u6216\u8005\u662f\u811a\u672c\u9519\u8bef\u5bfc\u81f4\u7684\u3002\u6b64\u65f6\uff0c\u68c0\u67e5\u811a\u672c\u662f\u5426\u5df2\u6b63\u786e\u6302\u5728\u542b\u6709Box\u7ec4\u4ef6\u7684\u6e38\u620f\u5bf9\u8c61\u4e0a\uff0c\u4e14GetComponent\u7684\u4f7f\u7528\u8bed\u6cd5\u662f\u5426\u6b63\u786e\u3002<\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u9010\u6b65\u89e3\u51b3<code>GetComponent<\/code>\u627e\u4e0d\u5230Box\u7684\u95ee\u9898\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u786e\u8ba4\u7ec4\u4ef6\u548c\u5bf9\u8c61\u7684\u547d\u540d<\/h3>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u786e\u8ba4\u4f60\u6b63\u5728\u67e5\u627e\u7684\u662f\u4e00\u4e2a\u7ec4\u4ef6\u800c\u4e0d\u662f\u6e38\u620f\u5bf9\u8c61\u7684\u540d\u79f0\u3002<code>GetComponent<\/code>\u65b9\u6cd5\u662f\u7528\u6765\u67e5\u627e\u548c\u83b7\u53d6\u6e38\u620f\u5bf9\u8c61\u4e2d\u7684\u7ec4\u4ef6\u7684\uff0c\u800c\u4e0d\u662f\u6e38\u620f\u5bf9\u8c61\u672c\u8eab\u3002\u786e\u4fdd\u4f7f\u7528\u7684\u662f\u6b63\u786e\u7ec4\u4ef6\u7684\u540d\u79f0\uff0c\u4f8b\u5982<code>BoxCollider<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u68c0\u67e5\u7ec4\u4ef6\u662f\u5426\u5df2\u6dfb\u52a0\u5230\u6e38\u620f\u5bf9\u8c61<\/h3>\n<\/p>\n<p><p>\u5728Unity\u4e2d\uff0c\u4efb\u4f55\u60f3\u8981\u901a\u8fc7<code>GetComponent<\/code>\u65b9\u6cd5\u83b7\u53d6\u7684\u7ec4\u4ef6\u90fd\u5fc5\u987b\u5148\u88ab\u6dfb\u52a0\u5230\u5bf9\u5e94\u7684\u6e38\u620f\u5bf9\u8c61\u4e0a\u3002\u6253\u5f00Unity\u7f16\u8f91\u5668\uff0c\u9009\u62e9\u5305\u542bBox\u7684\u6e38\u620f\u5bf9\u8c61\uff0c\u7136\u540e\u68c0\u67e5Inspector\u9762\u677f\u4e2d\u662f\u5426\u5b58\u5728\u4f60\u60f3\u83b7\u53d6\u7684\u7ec4\u4ef6\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u6dfb\u52a0\u7ec4\u4ef6<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u6ca1\u6709\uff0c\u4f60\u9700\u8981\u624b\u52a8\u6dfb\u52a0\u3002\u70b9\u51fb\u6e38\u620f\u5bf9\u8c61\uff0c\u5728Inspector\u9762\u677f\u7684\u5e95\u90e8\u70b9\u51fb\u201cAdd Component\u201d\uff0c\u7136\u540e\u641c\u7d22\u5e76\u6dfb\u52a0\u4f60\u60f3\u8981\u7684Box\u76f8\u5173\u7ec4\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><h3>\u4e09\u3001\u786e\u4fdd\u811a\u672c\u6302\u8f7d\u6b63\u786e<\/h3>\n<\/p>\n<p><p>\u7ec4\u4ef6\u6dfb\u52a0\u540e\uff0c\u8fd8\u9700\u786e\u8ba4C#\u811a\u672c\u662f\u5426\u6302\u8f7d\u5230\u4e86\u6b63\u786e\u7684\u6e38\u620f\u5bf9\u8c61\u4e0a\u3002\u5982\u679c\u4f60\u7684\u811a\u672c\u6302\u8f7d\u5230\u4e86\u5176\u4ed6\u6e38\u620f\u5bf9\u8c61\uff0c\u4f46\u662f\u5e0c\u671b\u83b7\u53d6\u7684\u7ec4\u4ef6\u5728\u53e6\u4e00\u4e2a\u6e38\u620f\u5bf9\u8c61\u4e0a\uff0c<code>GetComponent<\/code>\u5c06\u8fd4\u56denull\uff0c\u56e0\u4e3a\u5b83\u9ed8\u8ba4\u67e5\u627e\u5f53\u524d\u6e38\u620f\u5bf9\u8c61\u4e0a\u7684\u7ec4\u4ef6\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u6302\u8f7d\u811a\u672c<\/strong><\/p>\n<\/p>\n<p><p>\u786e\u8ba4\u811a\u672c\u5df2\u7ecf\u88ab\u6302\u8f7d\u5230\u62e5\u6709Box\u7ec4\u4ef6\u7684\u6e38\u620f\u5bf9\u8c61\u4e0a\u3002\u5982\u679c\u4e0d\u662f\uff0c\u62d6\u52a8\u811a\u672c\u5230\u6b63\u786e\u7684\u6e38\u620f\u5bf9\u8c61\u4e0a\uff0c\u6216\u8005\u5728\u811a\u672c\u4e2d\u4f7f\u7528<code>GameObject.Find<\/code>\u6216\u8005\u5176\u4ed6\u65b9\u6cd5\u6765\u5f15\u7528\u6b63\u786e\u7684\u6e38\u620f\u5bf9\u8c61\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><h3>\u56db\u3001\u68c0\u67e5\u5c42\u7ea7\u5173\u7cfb\u548c\u811a\u672c\u9519\u8bef<\/h3>\n<\/p>\n<p><p>\u6709\u65f6\u5019\uff0c\u5373\u4f7f\u524d\u9762\u7684\u6b65\u9aa4\u6b63\u786e\u5b8c\u6210\uff0c<code>GetComponent<\/code>\u4ecd\u7136\u53ef\u80fd\u8fd4\u56denull\uff0c\u8fd9\u53ef\u80fd\u662f\u56e0\u4e3a\u6e38\u620f\u5bf9\u8c61\u7684\u5c42\u7ea7\u5173\u7cfb\u6216\u8005\u662f\u4ee3\u7801\u7ea7\u7684\u95ee\u9898\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u5c42\u7ea7\u5173\u7cfb<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679cBox\u7ec4\u4ef6\u5728\u5b50\u5bf9\u8c61\u800c\u4e0d\u662f\u5f53\u524d\u811a\u672c\u6240\u6302\u8f7d\u7684\u6e38\u620f\u5bf9\u8c61\u4e2d\uff0c\u9700\u8981\u4f7f\u7528<code>GetComponentInChildren<\/code>\u6765\u83b7\u53d6\u3002\u5982\u679cBox\u7ec4\u4ef6\u5728\u7236\u5bf9\u8c61\u4e2d\uff0c\u5219\u9700\u8981\u4f7f\u7528<code>GetComponentInParent<\/code>\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u811a\u672c\u9519\u8bef<\/strong><\/p>\n<\/p>\n<p><p>\u540c\u6837\uff0c\u68c0\u67e5C#\u4ee3\u7801\u662f\u5426\u6709\u8bed\u6cd5\u9519\u8bef\u6216\u8005\u903b\u8f91\u9519\u8bef\u3002\u6bd4\u5982\u4f7f\u7528<code>GetComponent&lt;Type&gt;()<\/code>\u65f6\uff0cType\u5e94\u8be5\u66ff\u6362\u4e3a\u6b63\u786e\u7684\u7ec4\u4ef6\u7c7b\u578b\u540d\u79f0\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><h3>\u4e94\u3001\u4f7f\u7528\u6b63\u786e\u7684\u8bed\u6cd5\u548c\u7c7b\u578b<\/h3>\n<\/p>\n<p><p>\u5728Unity\u4e2d\u4f7f\u7528<code>GetComponent<\/code>\u65f6\uff0c\u5fc5\u987b\u786e\u4fdd\u63d0\u4f9b\u7684\u7c7b\u578b\u53c2\u6570\u662f\u6b63\u786e\u7684\u3002\u5982\u679c\u7ec4\u4ef6\u4e3a\u81ea\u5b9a\u4e49\u7c7b\uff0c\u786e\u4fdd\u7c7b\u540d\u6b63\u786e\uff0c\u5e76\u4e14\u7c7b\u672c\u8eab\u4e0d\u662f\u62bd\u8c61\u7684\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u8bed\u6cd5\u793a\u4f8b<\/strong><\/p>\n<\/p>\n<p><pre><code class=\"language-csharp\">BoxCollider boxCollider = GetComponent&lt;BoxCollider&gt;();<\/p>\n<p>if (boxCollider == null)<\/p>\n<p>{<\/p>\n<p>    Debug.Log(&quot;BoxCollider not found on the game object.&quot;);<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>BoxCollider<\/code>\u662f\u5e94\u5f53\u88ab\u67e5\u8be2\u7684\u7ec4\u4ef6\u7c7b\u578b\uff0c\u9700\u8981\u786e\u4fdd\u6ca1\u6709\u62fc\u5199\u9519\u8bef\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><h3>\u516d\u3001\u68c0\u67e5\u7ec4\u4ef6\u542f\u7528\u72b6\u6001<\/h3>\n<\/p>\n<p><p>\u5373\u4f7fBox\u7ec4\u4ef6\u5728\u6e38\u620f\u5bf9\u8c61\u4e0a\u5b58\u5728\uff0c\u4f46\u5982\u679c\u5b83\u88ab\u7981\u7528\u4e86\uff08\u5373\u52fe\u9009\u6846\u672a\u88ab\u52fe\u9009\uff09\uff0c<code>GetComponent<\/code>\u4ecd\u7136\u4f1a\u8fd4\u56de\u5b83\u3002\u5982\u679c\u6709\u57fa\u4e8e\u7ec4\u4ef6\u662f\u5426\u542f\u7528\u7684\u7279\u5b9a\u903b\u8f91\uff0c\u9700\u8981\u68c0\u67e5\u7ec4\u4ef6\u7684<code>enabled<\/code>\u5c5e\u6027\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u68c0\u67e5\u7ec4\u4ef6\u72b6\u6001<\/strong><\/p>\n<\/p>\n<p><pre><code class=\"language-csharp\">BoxCollider boxCollider = GetComponent&lt;BoxCollider&gt;();<\/p>\n<p>if (boxCollider != null &amp;&amp; !boxCollider.enabled)<\/p>\n<p>{<\/p>\n<p>    Debug.Log(&quot;BoxCollider is present but disabled.&quot;);<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<p><p>\u7efc\u4e0a\u6240\u8ff0\uff0c\u901a\u8fc7\u4e0a\u8ff0\u6b65\u9aa4\uff0c\u901a\u5e38\u53ef\u4ee5\u627e\u5230\u5e76\u89e3\u51b3<code>GetComponent<\/code>\u627e\u4e0d\u5230Box\u7684\u95ee\u9898\u3002\u52a1\u5fc5\u8be6\u7ec6\u68c0\u67e5\u4f60\u7684\u6e38\u620f\u5bf9\u8c61\u3001\u7ec4\u4ef6\u5b58\u5728\u6027\u3001\u811a\u672c\u6302\u8f7d\u4f4d\u7f6e\uff0c\u4ee5\u53ca\u4ee3\u7801\u5b9e\u73b0\u7684\u6b63\u786e\u6027\u3002\u5982\u679c\u95ee\u9898\u4ecd\u7136\u5b58\u5728\uff0c\u5728\u8bba\u575b\u548c\u793e\u533a\u5bfb\u6c42\u5e2e\u52a9\u4e5f\u662f\u89e3\u51b3\u95ee\u9898\u7684\u4e00\u4e2a\u6709\u6548\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>\u95ee\u98981\uff1a\u6211\u7684Unity C#\u4ee3\u7801\u4e2d\u4f7f\u7528GetComponent\u65f6\u65e0\u6cd5\u627e\u5230Box\uff0c\u8be5\u5982\u4f55\u89e3\u51b3\uff1f<\/strong><\/p>\n<p>\u56de\u7b54\uff1a\u5728\u4f7f\u7528GetComponent\u51fd\u6570\u65f6\u65e0\u6cd5\u627e\u5230Box\uff0c\u53ef\u80fd\u6709\u51e0\u4e2a\u539f\u56e0\u5bfc\u81f4\u8fd9\u79cd\u60c5\u51b5\u3002\u9996\u5148\uff0c\u786e\u4fdd\u4f60\u7684\u4ee3\u7801\u4e2d\u6b63\u786e\u5f15\u7528\u4e86Box\u7ec4\u4ef6\u6240\u5728\u7684\u547d\u540d\u7a7a\u95f4\u3002\u5176\u6b21\uff0c\u68c0\u67e5\u4f60\u7684\u5bf9\u8c61\u662f\u5426\u786e\u5b9e\u5b58\u5728\u4e00\u4e2aBox\u7ec4\u4ef6\uff0c\u5e76\u4e14\u8be5\u7ec4\u4ef6\u88ab\u6b63\u786e\u547d\u540d\u4e3a&quot;Box&quot;\u3002\u53e6\u5916\uff0c\u8fd8\u8981\u786e\u4fdd\u4f60\u7684\u4ee3\u7801\u662f\u5728\u6267\u884c\u4e4b\u524d\u786e\u4fdd\u573a\u666f\u4e2d\u7684\u5bf9\u8c61\u5df2\u7ecf\u88ab\u52a0\u8f7d\u3002\u6700\u540e\uff0c\u4f60\u8fd8\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528\u5176\u4ed6\u65b9\u6cd5\u6765\u83b7\u53d6\u548c\u67e5\u627eBox\u7ec4\u4ef6\uff0c\u5982\u4f7f\u7528GameObject.GetComponentInChildren\u51fd\u6570\u6216\u8005\u4f7f\u7528GameObject.Find\u65b9\u6cd5\u3002<\/p>\n<p><strong>\u95ee\u98982\uff1a\u4e3a\u4ec0\u4e48\u6211\u7684Unity C#\u4ee3\u7801\u4e2d\u7684GetComponent\u51fd\u6570\u65e0\u6cd5\u627e\u5230\u6240\u9700\u7684Box\u7ec4\u4ef6\uff1f\u8be5\u5982\u4f55\u89e3\u51b3\uff1f<\/strong><\/p>\n<p>\u56de\u7b54\uff1a\u5f53\u4f60\u5728Unity C#\u4ee3\u7801\u4e2d\u4f7f\u7528GetComponent\u51fd\u6570\u65e0\u6cd5\u627e\u5230\u6240\u9700\u7684Box\u7ec4\u4ef6\u65f6\uff0c\u53ef\u80fd\u662f\u7531\u4e8e\u51e0\u4e2a\u539f\u56e0\u5bfc\u81f4\u7684\u3002\u9996\u5148\uff0c\u786e\u4fdd\u4f60\u7684\u811a\u672c\u6240\u9644\u52a0\u7684\u6e38\u620f\u5bf9\u8c61\u4e0a\u786e\u5b9e\u5b58\u5728\u4e00\u4e2aBox\u7ec4\u4ef6\u3002\u5982\u679c\u6ca1\u6709\uff0c\u4f60\u9700\u8981\u5728\u6e38\u620f\u5bf9\u8c61\u4e0a\u6dfb\u52a0\u8be5\u7ec4\u4ef6\u3002\u5176\u6b21\uff0c\u68c0\u67e5\u4f60\u7684\u811a\u672c\u662f\u5426\u6b63\u786e\u5730\u5f15\u7528\u4e86Box\u7ec4\u4ef6\u6240\u5728\u7684\u547d\u540d\u7a7a\u95f4\u3002\u8fd8\u8981\u6ce8\u610f\u68c0\u67e5\u4f60\u7684Box\u7ec4\u4ef6\u662f\u5426\u662f\u5728\u573a\u666f\u4e2d\u88ab\u6b63\u786e\u547d\u540d\u4e3a&quot;Box&quot;\u3002\u6700\u540e\uff0c\u4f60\u80fd\u5c1d\u8bd5\u4f7f\u7528\u5176\u4ed6\u65b9\u6cd5\u83b7\u53d6Box\u7ec4\u4ef6\uff0c\u4f8b\u5982\u4f7f\u7528GameObject.GetComponentInChildren\u51fd\u6570\u6216\u8005\u4f7f\u7528GameObject.Find\u65b9\u6cd5\u3002<\/p>\n<p><strong>\u95ee\u98983\uff1a\u5728\u6211\u7684Unity C#\u4ee3\u7801\u4e2d\uff0c\u65e0\u6cd5\u901a\u8fc7GetComponent\u627e\u5230Box\u7ec4\u4ef6\uff0c\u6709\u4ec0\u4e48\u89e3\u51b3\u65b9\u6cd5\uff1f<\/strong><\/p>\n<p>\u56de\u7b54\uff1a\u5728Unity C#\u4ee3\u7801\u4e2d\u4f7f\u7528GetComponent\u51fd\u6570\u65e0\u6cd5\u627e\u5230Box\u7ec4\u4ef6\u65f6\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4e0b\u9762\u7684\u89e3\u51b3\u65b9\u6848\u3002\u9996\u5148\uff0c\u786e\u4fdd\u4f60\u7684\u4ee3\u7801\u6b63\u786e\u5f15\u7528\u4e86\u5305\u542bBox\u7ec4\u4ef6\u7684\u547d\u540d\u7a7a\u95f4\u3002\u5176\u6b21\uff0c\u68c0\u67e5\u4f60\u7684\u811a\u672c\u6240\u9644\u52a0\u7684\u6e38\u620f\u5bf9\u8c61\u4e0a\u662f\u5426\u5b58\u5728\u4e00\u4e2a\u540d\u4e3a&quot;Box&quot;\u7684Box\u7ec4\u4ef6\u3002\u5982\u679c\u6ca1\u6709\uff0c\u4f60\u9700\u8981\u5728\u5bf9\u8c61\u4e0a\u6dfb\u52a0\u8be5\u7ec4\u4ef6\u3002\u53e6\u5916\uff0c\u8fd8\u8981\u786e\u4fdd\u5728\u6267\u884c\u83b7\u53d6\u7ec4\u4ef6\u7684\u4ee3\u7801\u4e4b\u524d\uff0c\u6e38\u620f\u5bf9\u8c61\u5df2\u7ecf\u5728\u573a\u666f\u4e2d\u88ab\u6b63\u786e\u52a0\u8f7d\u3002\u5982\u679c\u95ee\u9898\u4ecd\u7136\u5b58\u5728\uff0c\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528\u5176\u4ed6\u65b9\u6cd5\u83b7\u53d6\u548c\u67e5\u627eBox\u7ec4\u4ef6\uff0c\u4f8b\u5982\u4f7f\u7528GetComponentInChildren\u51fd\u6570\u6216\u8005\u4f7f\u7528FindObjectOfType\u65b9\u6cd5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Unity\u4e2d\uff0c\u5982\u679c\u4f7f\u7528GetComponent\u627e\u4e0d\u5230Box\u7ec4\u4ef6\uff0c\u53ef\u80fd\u539f\u56e0\u5305\u62ec\u547d\u540d\u9519\u8bef\u3001\u7ec4\u4ef6\u672a\u6dfb\u52a0\u3001\u5c42\u7ea7\u4e0d\u6b63\u786e [&hellip;]","protected":false},"author":3,"featured_media":266791,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/266789"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=266789"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/266789\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/266791"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=266789"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=266789"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=266789"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}