- Home /
GameObject.SetActive slow
So I am using some basic object pooling for my endless runner game. I have noticed that there is a random lag spike every once in a while, so I opened the Unity Profiler to see what was going on. I then noticed that there was a BIG spike, where 98% of my processor was being used for one frame. I went in the Frame Debugger to see what it was, and I noticed that GameObjec.SetActive was causing this. Here is an image:
I have no idea what would cause this, could someone please help? GameObject.SetActive calls GameObject.Activate() which calls Mesh.Bake and creates lag.
there's a lot of "Grass_P something" related to it. is the whole thing a terrain your toggling? A guess is you're not uniformly scaling those. Other than that, SetActive gets more expensive the more stuff it's toggling. maybe only moving the object pooled out of sight is enough
Your answer
Follow this Question
Related Questions
Understanding Profiler and Optimization ! 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Why Do My Obstacles Do This In My Object Pooler? 1 Answer
Help with making script efficient 3 Answers