CPU Usage ?
Hey guys, i'm working on a small game and i've already been experiencing FPS drops and managed to fix them by trial and error, but i'm asking this so i can know in the future where to look, so here it is: What in scripts takes the most CPU usage ?
Nameley i heard that it's best to have as little different scripts as possible, and that i should use as least function calls as i can, and overall not write anything useless (too much variable declarations, countless variable checks ect..) so i'd like to know what's true in all this and what's not. Also what style of writing, if any, would be the most CPU friendly.
Answer by NicholasSheehan · Mar 23, 2017 at 03:13 PM
It doesn't matter if you have 10 or 100 scripts, performance is dependent on what those scripts do.
As for writing styles to reduce CPU usage, the only tip I can recommend is don't leave any empty Start()
or Update()
methods, even though they are empty, they still use CPU usage due to how unity calls those methods.
You can use Unity's built-in profiler to see hat scripts are using up the most CPU usage, as well as any garbage your scripts create.
More info on the profiler here: https://docs.unity3d.com/Manual/Profiler.html
Your answer
Follow this Question
Related Questions
Removing a script if its only use is the Start function 1 Answer
Performance Problem: Unaccounted time between: LateBehaviourUpdate and CanvasRenderer.SyncTransform 2 Answers
Should occlusion culling be used in multiplayer games? 0 Answers
Any drawbacks to using LOD groups? 1 Answer
Game gets slower for certain resolutions in Unity Editor. What could be possible fix? 0 Answers