Unity3d 周分享(21期 2019.7.30 )

这篇博客汇总了Unity3d的相关技术分享,重点关注性能优化和实用工具。内容涵盖CullingGroups优化大规模对象移动、Excel比较工具、编译错误检查、Android设备StreamingAssets性能、Ian Dundore的性能最佳实践演讲、音频系统和Lua调试提示等。此外,还讨论了错误修复步骤、Unity的键盘快捷键、机型适配、动态字体生成、FPS显示方法和内存管理等多个方面。
摘要由CSDN通过智能技术生成

选自过去1~2周 自己所看到外文内容:https://twitter.com/unity3d 和各种其他博客来源吧 

 

1、 官方文档中提到一个优化: 不知道性能到底如何~~

Mass object movement & CullingGroups

As mentioned in the section on Transform Manipulation, moving large Transform hierarchies has a relatively high CPU cost due to the propagation of change messages. However, in real development environments, it is often impossible to collapse a hierarchy to a modest number of GameObjects.

At the same time, it is good development practice to only run enough behavior to maintain the believability of the game world while eliminating behavior the user will not notice – for example, in a Scene with a large number of characters, it is always more optimal to only run Mesh-skinning and animation-driven Transform movement for characters that are on-screen. There is no reason to waste CPU time calculating purely visual elements of the simulation for characters that are off-screen.

Both of these problems can be neatly addressed with an API first introduced in Unity 5.1: CullingGroups.

Instead of directly manipulating a large group of GameObjects in the scene, change the system to manipulate the Vector3 parameters of a group of BoundingSpheres within a CullingGroup. Each BoundingSphere serves as the authoritative repository for a single game-logical entity’s world-space position, and receives callbacks when the entity moves near/within the frustum of the CullingGroup’s main camera. These callbacks can then be used to activate/deactivate code or components (such as Animators) governing behavior that should only run while the entity is visible.

大量对象移动和剔除群组

如同 Transform Manipulation 那节所述,移动有超大层级结构的 Transform 对象会造成很大的 CPU 消耗。但在现实的环境中,通常不可能将对象结构精简到最少的 GameObjects。

同时,如果可以最好在玩家不发现的前提下,删除玩家看不到的行为。例如,在有大量角色的场景时,只针对屏幕可见范围内的角色计算网格蒙皮(Mesh-skinning)和处理角色动作等等。不需要浪费CPU的资源在计算屏幕外看不到的角色行为。

这两个问题都可以透过 Unity 5.1 导入的 API 来完美解决:CullingGroups。

与其直接操作场景中一大群的 GameObject,而是改变系统操作 CullingGroup 里的一组 BoundingSpheres 的Vector3 参数。每个 BoundingSphere 作为这些 GameObject 在游戏世界中的代表,当 CullingGroup 接近或进入CullingGroup 设定的主镜头的锥体范围内时成员才会收到 callback。然后这些 callback 就可以用来执行启用/停用的程序代码或组件(例如Animators)让物体执行在可见范围内该有的行为。

https://docs.unity3d.com/2018.2/Documentation/Manual/BestPracticeUnderstandingPerformanceInUnity8.html

 

https://docs.unity3d.com/ScriptReference/CullingGroup.html

https://docs.unity3d.com/2018.2/Documentation/Manual/CullingGroupAPI.html

https://unitycoder.com/blog/2018/10/31/find-nearby-objects-using-cullinggroup/

有两种方式来触发CullingGroup的事件:

  • 相机裁剪
  • 相对距离(相机或主主角相对于目标物体的距离)

这两种方式可以混用,也可以只使用其中一个

应用场景有:

  • 粒子当前不可见时,将其暂停
  • 粒子与相机或主角在不同距离阶段时,使用不同的简化版粒子。
  • ai不在视野内时停止更新

剔除组是Unity API的一部分,它有效地允许我们创建自己的自定义LOD系统,作为一种方法来提出我们自己的动态替换某些游戏玩法或渲染行为的方法。我们可能希望应用LOD的一些示例包括 用具有较少骨骼的版本替换动画角色,应用更简单的着色器,远距离跳过粒子系统生成,简化AI行为等等。它在游戏玩法领域也有其他用途,

例如确定某些敌人出生点当前是否对玩家可见或者Player是否正在接近某些区域。有各种各样的可能性可与Culling Group系统一起使用,值得考虑。当然,花在实施,测试和重新设计场景上的时间可能很重要。

unity_2017_game_optimization_second_edition.pdf : 建议有时间阅读一下此书 http://www.dphgame.com/lib/exe/fetch.php?media=unity_2017_game_optimization_second_edition.pdf

Mesh-based LOD :基于网格的LOD也将耗费我们的磁盘空间以及RAM和CPU;

有些可能真的不要使用这个技术,比如 总是在室内或固定视角的俯视相机,包括实时战略(RTS)和多人在线战斗竞技场(MOBA)游戏。

 

 

 

2、 关于微软自己的 Excel比较工具: 好像Office 2013 就有这个工具了~

https://support.office.com/en-us/article/compare-two-versions-of-a-workbook-by-using-spreadsheet-compare-0e1627fd-ce14-4c33-9ab1-8ea82c6a5a7e

https://support.office.com/en-us/article/merge-copies-of-a-shared-workbook-aa7c3598-5ad7-4fea-8c00-2daa7a934239#OfficeVersion=Windows

https://answers.microsoft.com/en-us/msoffice/forum/all/comparing-excel-files/bb190de7-a029-4a6b-87b4-08db6a28f397

这个比较看着挺舒服的。

 

git工具中使用

https://www.syntevo.com/doc/display/SG/External+Tools%3A+configuring+Microsoft+Excel+spreadsheet+diffs

External Tools: configuring Microsoft Excel spreadsheet diffs

转至元数据结尾

转至元数据起始

If one has Microsoft Office installed, a tool called "SpreadSheet Compare" exists which is usually located at C:\Program Files (x86)\Microsoft Office\root\Office16\DCF\spreadsheetcompare. From command line, it takes a text file with two lines; each line is a file name.

To call this from SmartGit, in the Preferences, create a Diff Tool for e.g. *.xls pattern with Arguments ${leftFile} ${rightFile} and set Command to a script like the following:

@ECHO OFF rem smartgit diff passes two arguments: old-file, new-file. set TEMP_FILE=%TEMP%\smartgit-excel-diff.txt ECHO %1 > %TEMP_FILE% ECHO %2 >> %TEMP_FILE% "C:\Program Files\Microsoft Office\root\vfs\ProgramFilesX86\Microsoft Office\Office16\DCF\spreadsheetcompare" %TEMP_FILE%

For older/ 32-Bit MS Office versions, the executable's path may be:

"C:\Program Files (x86)\Microsoft Office\root\Office16\DCF\spreadsheetcompare"

 

 

Office 2019 快捷键中指认的是 : 第二个路径根本不存在,真不清楚是怎么执行的?

"C:\Program Files\Microsoft Office\root\Client\AppVLP.exe" "C:\Program Files (x86)\Microsoft Office\Office16\DCF\SPREADSHEETCOMPARE.EXE"

最后搜索到在这里:

C:\Program Files\Microsoft Office\root\vfs\ProgramFilesX86\Microsoft Office\Office16\DCF\SPREADSHEETCOMPARE.EXE

 

 

SVN :http://www.voidcn.com/article/p-nnccujmi-ro.html http://www.aichengxu.com/other/2533376.htm 有解释原理,但是注意这个是C盘路径,可能程序没有写的权限等 不会执行成功, 提供没有提供给SPREADSHEETCOMPARE路径,是因为 temp.txt 文件没有创建出来,更没有写入内容了。 设置路径权限就可以了。~~~

创建一个 ExcelCompare.bat 放到 SPREADSHEETCOMPARE.exe 同路径下。 然后SVN 设置中指认。 : C:\Program Files\Microsoft Office\root\vfs\ProgramFilesX86\Microsoft Office\Office16\DCF\ExcelCompare.bat %base %mine

 

@echo off

chcp 65001

set toolpath=%~dp0

echo %~1> "%toolpath%temp.txt"

echo %~2>> "%toolpath%temp.txt"

"%toolpath%SPREADSHEETCOMPARE.EXE" "%toolpath%temp.txt"

 

可以把 C:\Program Files\Microsoft Office\root\vfs\ProgramFilesX86\Microsoft Office\Office16\DCF 整个路径拷贝到其它地方或者 分享给其他组员使用(测试没有问题)。

  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值