{"id":8,"date":"2025-11-29T21:00:23","date_gmt":"2025-11-29T13:00:23","guid":{"rendered":"https:\/\/www.iamnpc.club\/?p=8"},"modified":"2025-11-29T21:00:23","modified_gmt":"2025-11-29T13:00:23","slug":"%e7%ac%94%e8%af%95%e9%a2%98%e6%b1%87%e6%80%bb%e6%9b%b4%e6%96%b0ing","status":"publish","type":"post","link":"https:\/\/www.iamnpc.club\/index.php\/2025\/11\/29\/%e7%ac%94%e8%af%95%e9%a2%98%e6%b1%87%e6%80%bb%e6%9b%b4%e6%96%b0ing\/","title":{"rendered":"\u7b14\u8bd5\u9898\u6c47\u603b(\u66f4\u65b0ing)"},"content":{"rendered":"\n<p><strong>\u95ee\uff1a\u4ec0\u4e48\u662f upvalue\uff1f\u4ed6\u6709\u4ec0\u4e48\u4f5c\u7528<\/strong><\/p>\n\n\n\n<p>\u5b83\u662f\u4e00\u4e2a\u65b9\u6cd5\u5185\u90e8\u91cc\u9762\u4f7f\u7528\u4e86\u81ea\u5df1\u5916\u5c42\u65b9\u6cd5\u7684\u5c40\u90e8\u53d8\u91cf<\/p>\n\n\n\n<p>\u5f53\u4e00\u4e2a\u65b9\u6cd5\u5f15\u7528\u4e86\u4e0d\u662f\u81ea\u5df1\u4f5c\u7528\u57df\u7684\u5c40\u90e8\u53d8\u91cf\uff0c\u8fd9\u4e2a\u53d8\u91cf\u5c06\u4f1a\u88ab\u95ed\u5305\u6355\u83b7\u3002\u5373\u4f7f\u5916\u90e8\u7684\u4f5c\u7528\u57df\u7684\u65b9\u6cd5\u5df2\u7ecf\u7ed3\u675f\uff0c\u5b83\u4f9d\u65e7\u53ef\u4ee5\u968f\u7740\u5185\u90e8\u7684\u65b9\u6cd5\u5b58\u6d3b\u3002<\/p>\n\n\n\n<p>\u5b83\u53ef\u4ee5\u8ba9\u5916\u5c42\u65b9\u6cd5\u7684\u5c40\u90e8\u53d8\u91cf\u6210\u4e3a\u81ea\u5df1\u5185\u90e8\u7684\u79c1\u6709\u73af\u5883\u4e2d\u7684\u53d8\u91cf<\/p>\n\n\n\n<p><strong>\u95ee\uff1a\u591a\u4e2a\u534f\u7a0b\u65f6\uff0c\u5806\u3001\u6808\u662f\u5426\u53ef\u4ee5\u5171\u4eab<\/strong><\/p>\n\n\n\n<p>\u5806\u53ef\u4ee5\uff0c\u6808\u4e0d\u884c\u3002<\/p>\n\n\n\n<p>\u5806\u662f\u5171\u4eab\u7684\u53ea\u8981\u6709\u5f15\u7528\u5c31\u53ef\u4ee5\u4f7f\u7528\uff0c\u6808\u6bcf\u4e2a\u534f\u7a0b\u72ec\u7acb\u4fdd\u5b58\u5c40\u90e8\u53d8\u91cf\u548c\u8c03\u7528\u73af\u5883\uff0c\u53ea\u80fd\u81ea\u5df1\u4f7f\u7528\u3002<\/p>\n\n\n\n<p><strong>\u95ee\uff1a\u542f\u7528\u534f\u7a0b\u7684 gameObject\u5173\u95ed\u540e\uff0c\u534f\u7a0b\u5904\u4e8e\u4ec0\u4e48\u72b6\u6001\uff1f<\/strong><\/p>\n\n\n\n<p>\u5982\u679c\u662factive(false)\u7684\u8bdd\u534f\u7a0b\u5c06\u4f1a\u7ee7\u7eed\u6267\u884c\u3002\u4f46\u662f\u5982\u679c\u76f4\u63a5\u5c06\u5176\u7684gameObject\u6216\u8005monobehaviour destory\u7684\u8bdd\u534f\u7a0b\u5c06\u4f1a\u88ab\u505c\u6b62<\/p>\n\n\n\n<p><strong>\u95ee\uff1a\u52a8\u3001\u9759\u5408\u6279\u662f\u4ec0\u4e48\u3001\u5b83\u4eec\u7684\u89e6\u53d1\u65f6\u673a\uff1f<\/strong><\/p>\n\n\n\n<p>\u9759\u6001\u5408\u6279\uff1a<\/p>\n\n\n\n<p>\u52fe\u9009\u4e86 <em>Static Batching<\/em> \u7684\u9759\u6001 GameObject \u4f1a\u5728\u573a\u666f\u52a0\u8f7d\u65f6\uff0c\u6839\u636e\u201c\u6750\u8d28\u662f\u5426\u76f8\u540c\u201d\u628a\u591a\u4e2a Mesh \u5408\u5e76\u6210\u4e00\u4e2a\u66f4\u5927\u7684 Mesh\uff0c\u4ee5\u51cf\u5c11 DrawCall\u3002<\/p>\n\n\n\n<p>\u5b83\u9002\u7528\u4e8e\u5b8c\u5168\u4e0d\u4f1a\u79fb\u52a8\u7684\u5bf9\u8c61\uff0c\u89e6\u53d1\u65f6\u673a\u901a\u5e38\u5728 <strong>\u573a\u666f\u52a0\u8f7d\u6216\u8fdb\u5165 Play \u6a21\u5f0f\u540e<\/strong>\u3002<\/p>\n\n\n\n<p>\u52a8\u6001\u5408\u6279\uff1a<\/p>\n\n\n\n<p>\u5bf9\u4e8e\u4f1a\u79fb\u52a8\u7684 GameObject\uff0c\u53ea\u8981\u5b83\u4eec\u4f7f\u7528\u5b8c\u5168\u76f8\u540c\u7684\u6750\u8d28\u5b9e\u4f8b\uff0c\u5e76\u4e14\u5355\u4e2a Mesh \u7684\u9876\u70b9\u6570\u8f83\u5c0f\uff08\u4e00\u822c\u5efa\u8bae 300 \u9876\u70b9\u4ee5\u5185\uff09\uff0cUnity \u5c31\u4f1a\u5728 <strong>\u6bcf\u4e00\u5e27<\/strong> \u7684 CPU \u7aef\u5c1d\u8bd5\u5c06\u5b83\u4eec\u4e34\u65f6\u5408\u6279\u6210\u4e00\u6279\u63d0\u4ea4\u7ed9 GPU\uff0c\u4ece\u800c\u51cf\u5c11 DrawCall\u3002<\/p>\n\n\n\n<p>\u52a8\u6001\u5408\u6279\u4e0d\u4f1a\u771f\u6b63\u628a Mesh \u5408\u6210\u4e00\u4e2a\uff0c\u800c\u662f\u628a\u591a\u6b21\u6e32\u67d3\u5408\u5e76\u6210\u4e00\u6b21\u63d0\u4ea4\u3002<\/p>\n\n\n\n<p>\u9759\u6001\u5408\u6279\u662f\u771f\u5408 mesh\uff0c\u52a8\u6001\u5408\u6279\u662f\u5047\u5408 mesh\u3001\u771f\u5408\u63d0\u4ea4\u3002<\/p>\n\n\n\n<p>\u524d\u8005\u662f\u9884\u5904\u7406\uff0c\u540e\u8005\u662f CPU \u6bcf\u5e27\u4e34\u65f6\u6253\u5305\u3002<\/p>\n\n\n\n<p><strong>\u95ee\uff1a<\/strong><strong>\u4f7f\u7528getComponentsInChildren\u83b7\u53d6\u7ec4\u4ef6\u65f6\uff0c\u662f\u5426\u4f1a\u5305\u542b\u81ea\u8eab<\/strong><\/p>\n\n\n\n<p>\u4f1a\uff0c\u5982\u679c\u6709\u7684\u8bdd<\/p>\n\n\n\n<p><strong>\u95ee\uff1aUnity\u4e2d\u900f\u660e\u7269\u4f53\u5728\u54ea\u4e2a\u9636\u6bb5\u8fdb\u884c\u7ed8\u5236<\/strong><\/p>\n\n\n\n<p>\u900f\u660e\u7269\u4f53\u662f\u5728\u4e0d\u900f\u660e\u7269\u4f53\u4e4b\u540e\u3001UI \u4e4b\u524d\uff0cRenderQueue = Transparent \u9636\u6bb5\u7ed8\u5236\u7684\u3002<\/p>\n\n\n\n<p><strong>\u95ee\uff1a\u4e00\u5f201024&#215;1024\u7684\u56fe\u7247\uff0c\u6700\u591a\u53ef\u4ee5\u751f\u6210\u591a\u5c11mipmap<\/strong><\/p>\n\n\n\n<p>\u6bcf\u4e00\u5c42\u4e3a\u4e4b\u524d\u7684\u4e00\u534a\uff0c\u5219\uff1alog2(1024) + 1 = 10 + 1 = 11<\/p>\n\n\n\n<p><strong>\u95ee\uff1a<\/strong><strong>\u7eb9\u7406\u538b\u7f29\u540e\uff0c\u6253\u5305\uff0c\u8fd0\u884c\u65f6\u663e\u5b58\u5b58\u653e\u54ea\u7c7b<\/strong><\/p>\n\n\n\n<p>\u7eb9\u7406\u538b\u7f29\u540e\u6253\u8fdb\u5305\uff0c\u8fd0\u884c\u65f6\u52a0\u8f7d\u8fdb GPU \u65f6\uff0cUnity \u4f1a\u628a\u7eb9\u7406\u8f6c\u6362\u6210 GPU \u539f\u751f\u538b\u7f29\u683c\u5f0f\uff08\u5982 ASTC \/ DXT \/ ETC2\uff09\u3002\u663e\u5b58\u4e2d\u5b58\u653e\u7684\u5c31\u662f\u8fd9\u4e2a GPU \u538b\u7f29\u683c\u5f0f\uff0c\u800c\u4e0d\u662f PNG\/JPG \u539f\u56fe\u6216 CPU \u7aef\u683c\u5f0f\u3002<\/p>\n\n\n\n<p><strong>\u95ee\uff1a\u89e3\u91ca\u4e00\u4e0blua\u7684\u5143\u8868\u662f\u4ec0\u4e48\uff1f<\/strong><\/p>\n\n\n\n<p>lua\u7684\u5143\u8868\u672c\u8eab\u4e0d\u4f1a\u66f4\u6539table\u7684\u7ed3\u6784\uff0c\u53ea\u662f\u4f1a\u4fee\u6539\u4e00\u4e9b\u884c\u4e3a\uff0c\u4f8b\u5982\u4fee\u6539\u67e5\u627e\u6216\u8005\u8bfb\u53d6\u7b49\u7684\u884c\u4e3a\u673a\u5236<\/p>\n\n\n\n<p><strong>\u95ee\uff1a\u5143\u8868\u4e2d\u5e38\u89c1\u7684\u539f\u65b9\u6cd5\u90fd\u6709\u54ea\u4e9b\uff1f<\/strong><\/p>\n\n\n\n<p>\u6700\u5e38\u89c1\u7684\u662f__index \u548c__newindex\u3002<\/p>\n\n\n\n<p>__index\u5f53\u8bbf\u95ee\u4e0d\u5b58\u5728\u7684key\u65f6\u4f1a\u51fa\u53d1\uff08\u4e00\u822c\u53ef\u4ee5\u4f5c\u4e3a\u7c7b\u7684\u6a21\u62df\u548c\u7ee7\u627f\u5e38\u7528\uff09\u5b83\u53ef\u4ee5\u662f\u4e00\u4e2atable\u6216\u8005function<\/p>\n\n\n\n<p>__newindex\u65f6\u662f\u5f53\u65b0\u589e\u4e00\u4e2a\u4e0d\u5b58\u5728\u7684key\u65f6\u4f1a\u89e6\u53d1(\u4e00\u822c\u505a\u53ea\u8bfb\u8868\u6216\u8005\u4e00\u4e9b\u5176\u4ed6\u9650\u5236\u65f6\u4f7f\u7528)\u3002\u53ef\u4ee5\u662f\u4e00\u4e2atable\u6216\u8005function<\/p>\n\n\n\n<p>\u9664\u6b64\u4e4b\u5916\uff0c<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>__add<\/strong>\uff1a\u91cd\u8f7d +<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>__tostring<\/strong>\uff1a\u6253\u5370 table \u65f6\u81ea\u5b9a\u4e49\u8f93\u51fa<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>__call<\/strong>\uff1a\u8ba9 table \u50cf\u51fd\u6570\u4e00\u6837\u88ab\u8c03\u7528<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>__eq<\/strong><strong> \/ <\/strong><strong>__lt<\/strong><strong> \/ <\/strong><strong>__le<\/strong>\uff1a\u6bd4\u8f83\u64cd\u4f5c<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>__gc<\/strong>\uff1auserdata \u7684\u6790\u6784\u65b9\u6cd5\uff08\u9762\u5411 C \u7ed1\u5b9a\uff09<\/li>\n<\/ul>\n\n\n\n<p><strong>\u95ee\uff1a\u5982\u4f55\u7528\u5143\u8868\u5b9e\u73b0\u201c\u7c7b\u201d\u6216\u201c\u7ee7\u627f\u201d\uff1f<\/strong><\/p>\n\n\n\n<p>lua\u672c\u8eab\u6ca1\u6709\u7c7b\uff0c\u4f46\u662f\u53ef\u4ee5\u7528\u5143\u8868\u6765\u6a21\u62df\u3002<\/p>\n\n\n\n<p>\u9996\u5148\u8ba9\u4f5c\u4e3a\u7c7b\u7684\u8868\u5c06__index\u8bbe\u7f6e\u4e3a\u81ea\u5df1<\/p>\n\n\n\n<p>\u7136\u540e\u5c06\u8981\u4f5c\u4e3a\u5b9e\u4f8b\u7684\u8868\u8bbe\u7f6e\u5143\u8868\u4e3a\u4f5c\u4e3a\u7c7b\u7684\u8868\u3002\u5982\u679c\u9700\u8981\u7ee7\u627f\u7684\u8bdd\uff0c\u90a3\u4e48\u53ef\u4ee5\u8ba9\u7236\u7c7b\u6210\u4e3a\u5b50\u7c7b\u7684index<\/p>\n\n\n\n<p>Animal = {} Animal.__index = Animal function Animal:new(name) local o = { name = name } setmetatable(o, self) return o end function Animal:Speak() print(self.name .. &#8221; says hi&#8221;) end<\/p>\n\n\n\n<p><strong>\u95ee: \u5143\u8868\u6709\u4ec0\u4e48\u5e38\u89c1\u7684\u7528\u9014\uff1f<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u9762\u5411\u5bf9\u8c61\uff08class\u3001\u7ee7\u627f\uff09<\/li>\n\n\n\n<li>\u4ee3\u7406\u8868\uff08\u76d1\u63a7\u8bfb\u5199\u3001\u53ea\u8bfb\u8868\uff09<\/li>\n\n\n\n<li>\u8fd0\u7b97\u7b26\u91cd\u8f7d\uff08+\u3001==\u3001&lt; \u2026\uff09<\/li>\n\n\n\n<li>\u81ea\u5b9a\u4e49 tostring\u3001call \u884c\u4e3a<\/li>\n\n\n\n<li>\u6027\u80fd\u4f18\u5316\uff08\u5171\u4eab\u65b9\u6cd5\u8868\uff09<\/li>\n<\/ul>\n\n\n\n<p><strong>\u95ee\uff1aref \u548c out \u7684\u533a\u522b<\/strong><\/p>\n\n\n\n<p>ref \u7528\u4e8e\u4f20\u5165\u5e76\u4fee\u6539\u5df2\u6709\u53d8\u91cf\uff0c\u56e0\u6b64\u8c03\u7528\u524d\u5fc5\u987b\u521d\u59cb\u5316\uff1bout \u7528\u4e8e\u8fd4\u56de\u591a\u4e2a\u503c\uff0c\u56e0\u6b64\u8c03\u7528\u524d\u4e0d\u9700\u8981\u521d\u59cb\u5316\uff0c\u4f46\u65b9\u6cd5\u5185\u90e8\u5fc5\u987b\u4e3a\u5b83\u8d4b\u503c\u3002\u4e24\u8005\u672c\u8d28\u4e0a\u90fd\u662f\u5f15\u7528\u4f20\u9012\uff0c\u53ea\u662f\u8bed\u4e49\u9650\u5236\u4e0d\u540c\u3002<\/p>\n\n\n\n<p><strong>\u95ee\uff1a\u8fdb\u7a0b\u548c\u534f\u7a0b\u7684\u533a\u522b<\/strong><\/p>\n\n\n\n<p>\u8fdb\u7a0b\u662f\u64cd\u4f5c\u7cfb\u7edf\u8c03\u5ea6\u7684\u72ec\u7acb\u6267\u884c\u5355\u5143\uff0c\u62e5\u6709\u81ea\u5df1\u7684\u5185\u5b58\u7a7a\u95f4\uff1b<\/p>\n\n\n\n<p>\u534f\u7a0b\u662f\u7528\u6237\u6001\u7684\u8f7b\u91cf\u7ea7\u4efb\u52a1\uff0c\u4f9d\u8d56\u6240\u5728\u7ebf\u7a0b\u8fd0\u884c\uff0c\u4e0d\u80fd\u5e76\u884c\uff0c\u53ea\u80fd\u901a\u8fc7 yield \u65f6\u95f4\u7247\u8f6e\u8f6c\u3002<\/p>\n\n\n\n<p><strong>\u95ee\uff1abyte int long float \u7684\u957f\u5ea6\u662f\u591a\u5c11\uff1f<\/strong><\/p>\n\n\n\n<p>byte \u662f1\u81ea\u5df1 int\u662f4\u5b57\u8282 long\u662f8\u5b57\u8282 float \u662f4\u5b57\u8282\u3002<\/p>\n\n\n\n<p><strong>\u95ee:for(byte i = 0; i &lt;= 255; ++i){ debug.log(i)} \u8fd9\u4e2a\u4f1a\u6253\u5370\u4ec0\u4e48\uff1f<\/strong><\/p>\n\n\n\n<p>\u65e0\u9650\u6253\u5370 0~255<\/p>\n\n\n\n<p><strong>\u95ee\uff1a1\u5b57\u8282\u7b49\u4e8e\u591a\u5c11byte<\/strong><\/p>\n\n\n\n<p>\u662f 1 \u4e2a\u5b57\u8282\uff08byte\uff09= 8 bit<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u95ee\uff1a\u4ec0\u4e48\u662f upvalue\uff1f\u4ed6\u6709\u4ec0\u4e48\u4f5c\u7528 \u5b83\u662f\u4e00\u4e2a\u65b9\u6cd5\u5185\u90e8\u91cc\u9762\u4f7f\u7528\u4e86\u81ea\u5df1\u5916\u5c42\u65b9\u6cd5\u7684\u5c40\u90e8\u53d8\u91cf \u5f53\u4e00\u4e2a\u65b9\u6cd5\u5f15\u7528\u4e86\u4e0d\u662f\u81ea\u5df1\u4f5c\u7528\u57df\u7684\u5c40\u90e8\u53d8\u91cf\uff0c\u8fd9\u4e2a\u53d8\u91cf\u5c06\u4f1a\u88ab\u95ed\u5305\u6355\u83b7\u3002\u5373\u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-8","post","type-post","status-publish","format-standard","hentry","category-3"],"_links":{"self":[{"href":"https:\/\/www.iamnpc.club\/index.php\/wp-json\/wp\/v2\/posts\/8","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.iamnpc.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.iamnpc.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.iamnpc.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.iamnpc.club\/index.php\/wp-json\/wp\/v2\/comments?post=8"}],"version-history":[{"count":1,"href":"https:\/\/www.iamnpc.club\/index.php\/wp-json\/wp\/v2\/posts\/8\/revisions"}],"predecessor-version":[{"id":9,"href":"https:\/\/www.iamnpc.club\/index.php\/wp-json\/wp\/v2\/posts\/8\/revisions\/9"}],"wp:attachment":[{"href":"https:\/\/www.iamnpc.club\/index.php\/wp-json\/wp\/v2\/media?parent=8"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.iamnpc.club\/index.php\/wp-json\/wp\/v2\/categories?post=8"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.iamnpc.club\/index.php\/wp-json\/wp\/v2\/tags?post=8"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}