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

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.

主站蜘蛛池模板: 措勤县| 芦溪县| 大城县| 南阳市| 涟源市| 兰溪市| 仲巴县| 邹城市| 湘乡市| 志丹县| 高阳县| 麻城市| 通渭县| 东港市| 射洪县| 衡东县| 米易县| 江油市| 河源市| 南部县| 龙门县| 江北区| 柘荣县| 峨眉山市| 文山县| 四子王旗| 鄂托克前旗| 临邑县| 大荔县| 安达市| 大田县| 临沧市| 凤山市| 龙井市| 盐城市| 隆尧县| 大渡口区| 铜山县| 准格尔旗| 高碑店市| 溧水县|