I really had no idea what to title this, because I am completely mystified by what is happening here.
Basically, I am making a game with a progress system. When a scene is loaded, if a variable for a certain event in the game is true, the script sets a GameObject with all the necessary children active or inactive accordingly. For example, in this problem's situation, I have a bunch of Lights stored in an empty parent object, which is set inactive before completing a certain quest. Once the quest is completed, then the lights 'turn on' - have the parent object set active.
At runtime, when I load the scene and the lights are set inactive, it runs fine for a bit, but performance progressively worsens and seems to hit rock bottom at 2-3 FPS after about five minutes of being in the scene. However, when I load the scene with the lights ON, performance is not an issue at all. Things got even weirder when I loaded the scene with the lights' parent object set inactive, waited for the lag to hit, and then manually activated the lights' parent object from the Inspector- and the lag disappeared entirely. As I type this, the scene still running and going on fifteen minutes with no problems.
I have no idea why having something as memory-heavy as lights set *inactive* would ruin performance so badly, and be able to be fixed at runtime by activating them. If anyone has ANY thoughts on this, I would greatly appreciate the help.
Potentially pertinent information:
-All of the lights are Point Lights, baked, have no shadows, render mode auto, and an Everything culling mask.
-Precomputed Realtime GI is disabled in this and all other scenes
-Multiple scenes use this "progress-on-load" system and script which activates and deactivates parent objects with large numbers of child objects, and no scene except the one in question has any problems.
-Baking of lights in every scene is set to Auto
-All the lights have a script on them that sets their intensity to zero when the player is a certain distance away.
-The console is not outputting any errors
-There are no new objects being instantiated or destroyed
**UPDATE**
I still have no idea what was causing the crippling amounts of lag, but I was able to fix it by loading the scene, waiting a short amount of time (I chose 0.25 seconds, but it's probably arbitrary), and THEN calling the method that chooses what objects to set active or inactive.
↧