官术网_书友最值得收藏!

Verifying script count

If we're looking at our Profiler data and note that a certain MonoBehaviour method is being executed more times than expected, or is taking longer than expected, we might want to double-check that it only occurs as many times in the scene as we expect it to. It's entirely feasible that someone created the object more times than expected in the scene file, or that we accidentally instantiated the object more than the expected number of times from code. If so, the problem could be due to conflicting or duplicated method invocations generating a performance bottleneck. We can verify the count using the same shortlist method used in the Best approaches to performance analysis section.

If we expected a specific number of components to appear in the scene, but the shortlist revealed more (or  fewer!) of these components, then it might be wise to write some initialization code that prevents this from ever happening again. We could also write some custom Editor helpers to display warnings to any level designers who might be making this mistake.

Preventing casual mistakes such as this is essential for good productivity, since experience tells us that, if we don't explicitly disallow something, then someone, somewhere, at some point, for whatever reason, will do it anyway. This is likely to cost us a frustrating afternoon hunting down a problem that eventually turned out to be caused by human error.

主站蜘蛛池模板: 绥滨县| 吉首市| 海晏县| 周宁县| 泰顺县| 巴彦淖尔市| 枝江市| 清流县| 石河子市| 乾安县| 西畴县| 滕州市| 曲阳县| 六枝特区| 无棣县| 孟村| 驻马店市| 哈巴河县| 溧水县| 湘潭县| 左贡县| 甘谷县| 北京市| 泰来县| 黄冈市| 库尔勒市| 土默特右旗| 绵阳市| 水富县| 西城区| 宣威市| 西平县| 通许县| 磐安县| 延庆县| 黑水县| 昌乐县| 厦门市| 大厂| 衡南县| 临湘市|