Unity Profiler Course
Using the unity Profiler, we can optimize the game but how do we optimize the code to optimize the game.
We can use Profiler inside the code to seal a set of code which can be used to confirm the frame spike from that set of code.
Here, Vector3 and GameObject both use new keyword but the Vector3 doesn’t cause frame spike as much as GameObject while using new keyword because Vector3 is a Struct which is a value type and does not allocate memory while GameObject is a Class which is a reference type and allocate memory. So you should cache the new keyword when using with reference types to optimize code.
It is also better to use List rather than Array as it is more performance friendly and easy to navigate and use.