cocos-enhance-kit/docs/best-practices/performance-guide/index.html
2024-12-20 14:47:15 +08:00

17 lines
25 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html lang="zh" dir="ltr" class="docs-wrapper docs-doc-page docs-version-3.0.0 plugin-docs plugin-id-default docs-doc-id-best-practices/performance-guide">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="generator" content="Docusaurus v2.0.0-beta.20">
<title data-rh="true">提升游戏性能 | Cocos Enhance Kit</title><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:url" content="https://smallmain.github.io/cocos-enhance-kit/docs/best-practices/performance-guide"><meta data-rh="true" name="docusaurus_locale" content="zh"><meta data-rh="true" name="docsearch:language" content="zh"><meta data-rh="true" name="docusaurus_version" content="3.0.0"><meta data-rh="true" name="docusaurus_tag" content="docs-default-3.0.0"><meta data-rh="true" name="docsearch:version" content="3.0.0"><meta data-rh="true" name="docsearch:docusaurus_tag" content="docs-default-3.0.0"><meta data-rh="true" property="og:title" content="提升游戏性能 | Cocos Enhance Kit"><meta data-rh="true" name="description" content="在游戏开发中享受不用关注 Draw Call 的快乐。"><meta data-rh="true" property="og:description" content="在游戏开发中享受不用关注 Draw Call 的快乐。"><link data-rh="true" rel="icon" href="/cocos-enhance-kit/img/favicon.ico"><link data-rh="true" rel="canonical" href="https://smallmain.github.io/cocos-enhance-kit/docs/best-practices/performance-guide"><link data-rh="true" rel="alternate" href="https://smallmain.github.io/cocos-enhance-kit/docs/best-practices/performance-guide" hreflang="zh"><link data-rh="true" rel="alternate" href="https://smallmain.github.io/cocos-enhance-kit/docs/best-practices/performance-guide" hreflang="x-default"><link rel="stylesheet" href="/cocos-enhance-kit/assets/css/styles.22998370.css">
<link rel="preload" href="/cocos-enhance-kit/assets/js/runtime~main.e047e124.js" as="script">
<link rel="preload" href="/cocos-enhance-kit/assets/js/main.a7d7118a.js" as="script">
</head>
<body class="navigation-with-keyboard">
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</script><div id="__docusaurus">
<div role="region"><a href="#" class="skipToContent_ZgBM">跳到主要内容</a></div><nav class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Navigation bar toggle" class="navbar__toggle clean-btn" type="button" tabindex="0"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/cocos-enhance-kit/"><b class="navbar__title text--truncate">Cocos Enhance Kit</b></a></div><div class="navbar__items navbar__items--right"><a class="navbar__item navbar__link" href="/cocos-enhance-kit/">首页</a><a class="navbar__item navbar__link navbar__link--active" href="/cocos-enhance-kit/docs/intro">文档</a><a href="https://smallmain.github.io/cocos-enhance-kit/demo/v1.0.0/web-desktop/index.html" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">演示</a><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a class="navbar__link" aria-haspopup="true" aria-expanded="false" role="button" href="/cocos-enhance-kit/docs/intro">3.0.0</a><ul class="dropdown__menu"><li><a class="dropdown__link" href="/cocos-enhance-kit/docs/next/best-practices/performance-guide">Next</a></li><li><a aria-current="page" class="dropdown__link dropdown__link--active" href="/cocos-enhance-kit/docs/best-practices/performance-guide">3.0.0</a></li><li><a class="dropdown__link" href="/cocos-enhance-kit/docs/2.4.0/best-practices/performance-guide">2.4.0</a></li><li><a class="dropdown__link" href="/cocos-enhance-kit/docs/2.3.0/best-practices/performance-guide">2.3.0</a></li><li><a class="dropdown__link" href="/cocos-enhance-kit/docs/2.2.0/best-practices/performance-guide">2.2.0</a></li><li><a class="dropdown__link" href="/cocos-enhance-kit/docs/2.1.0/best-practices/performance-guide">2.1.0</a></li><li><a class="dropdown__link" href="/cocos-enhance-kit/docs/2.0.0/best-practices/performance-guide">2.0.0</a></li><li><a class="dropdown__link" href="/cocos-enhance-kit/docs/1.2.0/intro">1.2.0</a></li><li><a class="dropdown__link" href="/cocos-enhance-kit/docs/1.1.0/intro">1.1.0</a></li><li><a class="dropdown__link" href="/cocos-enhance-kit/docs/1.0.0/intro">1.0.0</a></li></ul></div><a href="https://github.com/smallmain/cocos-enhance-kit" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link header-github-link">Github</a><div class="searchBox_dLyj"><div class="navbar__search searchBarContainer_NW3z"><input placeholder="搜索" aria-label="Search" class="navbar__search-input"><div class="loadingRing_RJI3 searchBarLoadingRing_YnHq"><div></div><div></div><div></div><div></div></div><div class="searchHintContainer_Pkmr"><kbd class="searchHint_iIMx">ctrl</kbd><kbd class="searchHint_iIMx">K</kbd></div></div></div><div class="toggle_S7eR colorModeToggle_vKtC"><button class="clean-btn toggleButton_rCf9 toggleButtonDisabled_Pu9x" type="button" disabled="" title="切换浅色/暗黑模式(当前为浅色模式)" aria-label="切换浅色/暗黑模式(当前为浅色模式)"><svg viewBox="0 0 24 24" width="24" height="24" class="lightToggleIcon_v35p"><path fill="currentColor" d="M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"></path></svg><svg viewBox="0 0 24 24" width="24" height="24" class="darkToggleIcon_nQuB"><path fill="currentColor" d="M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"></path></svg></button></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div class="main-wrapper docsWrapper_mKqt"><button aria-label="回到顶部" class="clean-btn theme-back-to-top-button backToTopButton_RiI4" type="button"></button><div class="docPage_ualW"><aside class="theme-doc-sidebar-container docSidebarContainer_UQUJ"><div class="sidebar_RiAD"><nav class="menu thin-scrollbar menu_izAj"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/cocos-enhance-kit/docs/intro">介绍</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="true" href="/cocos-enhance-kit/docs/installation/installation-auto">安装</a></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/cocos-enhance-kit/docs/installation/installation-auto">一键安装</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/cocos-enhance-kit/docs/installation/installation-manual">手动安装</a></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret menu__link--active" aria-expanded="true" href="/cocos-enhance-kit/docs/best-practices/performance-guide">最佳实践</a></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link menu__link--active" aria-current="page" tabindex="0" href="/cocos-enhance-kit/docs/best-practices/performance-guide">提升游戏性能</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/cocos-enhance-kit/docs/best-practices/quality-guide">提升游戏质量</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/cocos-enhance-kit/docs/best-practices/new-features">新引擎特性</a></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="true" href="/cocos-enhance-kit/docs/user-guide/multi-render/multi-render-intro">使用指南</a></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" tabindex="0" href="/cocos-enhance-kit/docs/user-guide/multi-render/multi-render-intro">多纹理渲染</a><button aria-label="打开/收起侧边栏菜单「多纹理渲染」" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" tabindex="0" href="/cocos-enhance-kit/docs/user-guide/text-render/text-render-intro">文本渲染</a><button aria-label="打开/收起侧边栏菜单「文本渲染」" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" tabindex="0" href="/cocos-enhance-kit/docs/user-guide/dynamic-batcher/dynamic-batcher-intro">动态合图</a><button aria-label="打开/收起侧边栏菜单「动态合图」" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" tabindex="0" href="/cocos-enhance-kit/docs/user-guide/spine/spine-intro">Spine</a><button aria-label="打开/收起侧边栏菜单「Spine」" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" tabindex="0" href="/cocos-enhance-kit/docs/user-guide/tiledmap/tiledmap-intro">TiledMap</a><button aria-label="打开/收起侧边栏菜单「TiledMap」" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" tabindex="0" href="/cocos-enhance-kit/docs/user-guide/multithread/thread-intro">多线程支持</a><button aria-label="打开/收起侧边栏菜单「多线程支持」" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" tabindex="0" href="/cocos-enhance-kit/docs/user-guide/profiler/profiler-intro">Profiler</a><button aria-label="打开/收起侧边栏菜单「Profiler」" type="button" class="clean-btn menu__caret"></button></div></li></ul></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/cocos-enhance-kit/docs/breaking-change">破坏性变更</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/cocos-enhance-kit/docs/uninstall-guide">卸载</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/cocos-enhance-kit/docs/update-log">更新日志</a></li></ul></nav></div></aside><main class="docMainContainer_uL0j"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_DM6M"><div class="docItemContainer_vinB"><article><nav class="theme-doc-breadcrumbs breadcrumbsContainer_Xlws" aria-label="页面路径"><ul class="breadcrumbs" itemscope="" itemtype="https://schema.org/BreadcrumbList"><li class="breadcrumbs__item"><a aria-label="主页面" class="breadcrumbs__link" href="/cocos-enhance-kit/"><svg viewBox="0 0 24 24" class="breadcrumbHomeIcon_kU5B"><path d="M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z" fill="currentColor"></path></svg></a></li><li class="breadcrumbs__item"><span class="breadcrumbs__link">最佳实践</span><meta itemprop="position" content="1"></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item breadcrumbs__item--active"><span class="breadcrumbs__link" itemprop="name">提升游戏性能</span><meta itemprop="position" content="2"></li></ul></nav><span class="theme-doc-version-badge badge badge--secondary">版本3.0.0</span><div class="tocCollapsible_bZGK theme-doc-toc-mobile tocMobile_TmEX"><button type="button" class="clean-btn tocCollapsibleButton_l22C">本页总览</button></div><div class="theme-doc-markdown markdown"><h1>提升游戏性能</h1><p>建议先阅读官方文档的 <a href="https://docs.cocos.com/creator/2.4/manual/zh/advanced-topics/ui-auto-batch.html" target="_blank" rel="noopener noreferrer">UI 渲染批次合并指南</a> 了解一些基础知识。</p><p>社区版对动态合图、文本渲染等功能进行了大量的改进,现在,你只需要确保以下几点就可以大幅提升游戏的性能。</p><h2 class="anchor anchorWithStickyNavbar_mojV" id="使用动态合图">使用动态合图<a class="hash-link" href="#使用动态合图" title="标题的直接链接"></a></h2><p>在之前,动态合图不支持复用图集的废弃区域,所以我们通常会关闭该特性,倾向于靠静态图集或者自动图集达到降低 Draw Call 的目的。</p><p>现在,社区版几乎重构了整个动态合图系统,实用性得到大幅提升:</p><ul><li>支持复用废弃区域</li><li>自动参与多纹理渲染 </li><li>支持 Spine 参与动态合图</li></ul><p>你只需要重新启用动态合图,并尽量让更多的纹理都参与合图,即可大幅降低 DrawCall 的数量。</p><p>我们还建议做以下调整:</p><p><strong>放宽能参与合图的纹理尺寸限制</strong></p><div class="language-js codeBlockContainer_MPoW theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_B9tL"><pre tabindex="0" class="prism-code language-js codeBlock__0OG thin-scrollbar"><code class="codeBlockLines_gEuF"><span class="token-line" style="color:#393A34"><span class="token plain">cc</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">dynamicAtlasManager</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">maxFrameSize</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1024</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// 推荐 512、1024 甚至 2048</span><br></span></code></pre><div class="buttonGroup_hRr1"><button type="button" aria-label="复制代码到剪贴板" title="复制" class="clean-btn"><span class="copyButtonIcons_W9eQ" aria-hidden="true"><svg class="copyButtonIcon_XEyF" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_i9w9" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>你可以根据游戏运行过程中所使用的动态图集数量,来逐步放宽限制,取得一个平衡点。</p><p><strong>优化动态图集的使用率</strong></p><p>当游戏使用的动态图集数量太多,你可以控制某个组件或纹理不参与动态合图:</p><ul><li>调整纹理的 <code>packable</code> 属性</li><li>调整组件的 <code>allowDynamicAtlas</code> 属性</li></ul><p>通过让某些优化性价比较低的纹理不参与合图,例如:</p><ul><li>大尺寸、单独出现的纹理:比如背景图,尺寸较大使得占用图集的空间大,并且一个场景内可能只有单个节点会显示,不存在需要大量合批的情况。</li></ul><p>来优化图集的使用。</p><p><strong>及时释放无用资源</strong></p><p>由于社区版支持了图集空间的复用,所以释放资源的同时也会将其占用的图集空间释放,以提供给其它纹理使用。</p><p>建议在不用的时候及时释放一些冷门资源,常用的资源则不进行释放,避免频繁释放后加载导致的性能消耗。</p><h2 class="anchor anchorWithStickyNavbar_mojV" id="使用-label-缓存模式">使用 Label 缓存模式<a class="hash-link" href="#使用-label-缓存模式" title="标题的直接链接"></a></h2><p>在之前,引擎提供的缓存模式都各有问题,无法在实际项目中使用:</p><ul><li><p>Bitmap 模式:虽然能够参与动态合图,但无法复用废弃空间,随着游戏的运行,废弃字符的纹理占满图集后就失去了优化效果。</p></li><li><p>Char 模式:依然是无法复用的问题,仅有一张字符纹理,当纹理被填满后甚至无法渲染出文本。</p></li></ul><p>现在,由于社区版使动态合图支持了复用,并且还重构了 Char 模式的实现,使得 你只需要合理运用这两种缓存模式即可完成对 Label 的优化工作。</p><p><strong>首选 Char 缓存模式</strong></p><p>我们建议 Label 默认使用 Char 缓存模式,相比 Bitmap 模式Char 模式是按字符进行复用的,有着更高的性能优势。</p><p><strong>备选 Bitmap 缓存模式</strong></p><p>如果遇到以下场景,则不适合使用 Char 模式进行渲染:</p><ul><li>显示像 Emoji 这种字素簇的字符串,由于内部实现无法分割为单个字符,所以不能正常显示。</li><li>超大字体,可能瞬间占满字符纹理。</li><li>显示聊天消息、输入框、玩家名称这类不可控的内容,由于第一条限制,所以为了保证 Label 能正常显示,则不建议使用。</li></ul><p>这时候就可以改用 Bitmap 模式进行渲染,依然能参与动态合图进行合批。</p><h3 class="anchor anchorWithStickyNavbar_mojV" id="注意事项">注意事项<a class="hash-link" href="#注意事项" title="标题的直接链接"></a></h3><ul><li><strong>勿对 <code>fontSize</code> 属性进行动画或者缓动</strong></li></ul><p>无论是否使用缓存模式,也不建议频繁修改 <code>fontSize</code> 属性,这会导致每帧都需要重新生成文字纹理,造成大量的性能消耗,可以转为使用节点的 <code>scale</code> 来代替。</p><ul><li><strong>Char 缓存模式依旧不能在内部字符纹理填满时正常渲染</strong></li></ul><p>这是引擎原本的限制,我们未对其进行修复,原因是我们认为 8 张数量已经够多了8 张都用完的情况大部分是没有合理搭配使用两种缓存模式。</p><h2 class="anchor anchorWithStickyNavbar_mojV" id="进行文本渲染烘焙">进行文本渲染烘焙<a class="hash-link" href="#进行文本渲染烘焙" title="标题的直接链接"></a></h2><p>在之前,即使没有 Drawcall 高的问题,引擎文本渲染本身的性能消耗也并不低。</p><p>为此,社区版新增了烘焙的相关接口,你可以通过这些接口将文本渲染的性能提升 10 倍以上!</p><p>可前往 <a href="/cocos-enhance-kit/docs/user-guide/text-render/text-baking">文本渲染烘焙</a> 文档了解更多详情。</p><h2 class="anchor anchorWithStickyNavbar_mojV" id="启用-spine-合批">启用 Spine 合批<a class="hash-link" href="#启用-spine-合批" title="标题的直接链接"></a></h2><p>Spine 组件现在不仅可以参与动态合图,还能与其他渲染组件进行合批。</p><p>只需启用组件上的 <code>Enable Batch</code> 属性即可。</p><h2 class="anchor anchorWithStickyNavbar_mojV" id="提升-tiledmap-性能">提升 TiledMap 性能<a class="hash-link" href="#提升-tiledmap-性能" title="标题的直接链接"></a></h2><p>一个 TiledMap 可能会有很多个 TiledLayer如果开启了 TiledMap 的 Culling 特性,则需要每个 Layer 都单独计算 Culling 数据。</p><p>社区版新增了在满足一定条件的情况下可以复用 Culling 数据的特性,以减少 CPU 的性能消耗。</p><p>可前往 <a href="/cocos-enhance-kit/docs/user-guide/tiledmap/tiledmap-culling">复用 Culling 数据</a> 文档了解更多详情。</p><h2 class="anchor anchorWithStickyNavbar_mojV" id="启用多线程支持">启用多线程支持<a class="hash-link" href="#启用多线程支持" title="标题的直接链接"></a></h2><p><strong>现在,以下引擎的部分增加了多线程支持:</strong></p><ul><li><strong>资源管线(下载与缓存部分)</strong></li><li><strong>音频系统</strong></li><li><strong>XMLHttpRequest</strong></li><li><strong>WebSocket</strong></li></ul><p>启用后可以释放其对主线程的占用,减少卡顿现象。</p><p>除此之外,还<strong>支持自定义多线程扩展</strong>,大幅简化了将项目逻辑多线程化所需的步骤!</p><p>并且在微信小游戏平台下还有以下改进:</p><ul><li><strong>默认启用网络接口和音频接口的高性能模式</strong></li><li><strong>网络接口支持 HTTP/2、HTTP/3(QUIC) 协议</strong></li></ul><p>详情请阅读文档:<a href="/cocos-enhance-kit/docs/user-guide/multithread/thread-intro">多线程支持</a></p></div></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="文档分页导航"><a class="pagination-nav__link pagination-nav__link--prev" href="/cocos-enhance-kit/docs/installation/installation-manual"><div class="pagination-nav__sublabel">上一页</div><div class="pagination-nav__label">手动安装</div></a><a class="pagination-nav__link pagination-nav__link--next" href="/cocos-enhance-kit/docs/best-practices/quality-guide"><div class="pagination-nav__sublabel">下一页</div><div class="pagination-nav__label">提升游戏质量</div></a></nav></div></div><div class="col col--3"><div class="tableOfContents_cNA8 thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#使用动态合图" class="table-of-contents__link toc-highlight">使用动态合图</a></li><li><a href="#使用-label-缓存模式" class="table-of-contents__link toc-highlight">使用 Label 缓存模式</a><ul><li><a href="#注意事项" class="table-of-contents__link toc-highlight">注意事项</a></li></ul></li><li><a href="#进行文本渲染烘焙" class="table-of-contents__link toc-highlight">进行文本渲染烘焙</a></li><li><a href="#启用-spine-合批" class="table-of-contents__link toc-highlight">启用 Spine 合批</a></li><li><a href="#提升-tiledmap-性能" class="table-of-contents__link toc-highlight">提升 TiledMap 性能</a></li><li><a href="#启用多线程支持" class="table-of-contents__link toc-highlight">启用多线程支持</a></li></ul></div></div></div></div></main></div></div></div>
<script src="/cocos-enhance-kit/assets/js/runtime~main.e047e124.js"></script>
<script src="/cocos-enhance-kit/assets/js/main.a7d7118a.js"></script>
</body>
</html>