Reducing the number of active objects by making objects inactive whenever possible

Optimization principal 1: Minimize the number of active and enabled objects in a scene.

Sometimes, we may not want to completely remove an object, but it is possible to go one step further than disabling a scripted component by making the parent GameObject that contains the scripted component inactive. This is just like deselecting the checkbox next to the GameObject in the Inspector, as shown in the following screenshot:

Reducing the number of active objects by making objects inactive whenever possible

How to do it...

To reduce computer processing workload requirements by making an object inactive when it becomes invisible, follow these steps:

  1. Copy ...

Get Unity 5.x Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.