- Home /
Speed and efficiency of enabling/disabling component?
I'm mainly talking about for scripts. Is component.enabled = false/true; slow? Because I was thinking about making my whole player movement system based off of states. Each state is a script component and I would be enabling/disabling these state components as the player changes states throughout the game. And since there will be many states for the player movement, i will be enabling and disabling these states A LOT, plus my whole game is about doing parkour and moving around so move states will be changing quite often. I need to make sure that this isn't going to eat up some performance, because I am shooting for a 60 fps game.
Answer by UnityCoach · Oct 25, 2018 at 10:39 AM
Unless you trigger a whole lot of mechanics in their OnDisable() and OnEnable() messages, it shouldn't.
The best way to tell would be to profile it. Here's an article I wrote a while back on profiling specific areas of your code.