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

  • Unity Game Optimization
  • Dr. Davide Aversa Chris Dickinson
  • 239字
  • 2021-06-24 12:12:59

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.

主站蜘蛛池模板: 精河县| 大丰市| 梓潼县| 岑溪市| 东港市| 札达县| 海城市| 信丰县| 赤水市| 抚宁县| 临清市| 英吉沙县| 光泽县| 钟山县| 青河县| 鄂伦春自治旗| 喀喇沁旗| 乌什县| 河北区| 萝北县| 招远市| 武胜县| 望谟县| 罗江县| 方山县| 鄂伦春自治旗| 灌南县| 沾化县| 盘锦市| 扶风县| 兴业县| 靖安县| 桃江县| 东安县| 大兴区| 桑日县| 简阳市| 永康市| 泊头市| 长葛市| 迭部县|