Your comments

Sure:

Start
SetupHalfSrqTransition
CalculateLODDistances
UsingUltraShader
UsingUltraShader
Update
--> Start
--> CreateTreeManager
--> LoadSaneStartingSettings
GetHighQualityShadowCastingMode
GetBillboardShadowCastingMode
ReCalculateParents
--> Reset
CalculateLODDistances
UsingUltraShader
--> SetupStaticMaterial
ApplyAll
FindTreeUsingFastShader
SetupHalfSrqTransition
CalculateLODDistances
UsingUltraShader
UsingUltraShader
--> Reset
CalculateLODDistances
UsingUltraShader
--> SetupStaticMaterial
CalculateLODDistances
UsingUltraShader
    >>> Repeating bit for each tree: <<<
--> DoShaderUpdate
--> GetBillboardLeavesShader
--> GetBillboardLeavesFarShader
UsingUltraShader
--> GetLeavesShader
UsingUltraShader
--> GetLeavesShader
UsingUltraShader
--> GetBarkShader
UsingUltraShader
--> GetBarkShader

I tried implementing the change. Unfortunately, it didn't solve the problem. It seems to be going through the following loop for each tree:


--> DoShaderUpdate
--> GetBillboardLeavesShader
--> GetBillboardLeavesFarShader
UsingUltraShader
--> GetLeavesShader
UsingUltraShader
--> GetLeavesShader
UsingUltraShader
--> GetBarkShader
UsingUltraShader
--> GetBarkShader

..then it proceeds to do this for just one of the trees:

--> Start
--> CreateTreeManager
--> LoadSaneStartingSettings
GetHighQualityShadowCastingMode
GetBillboardShadowCastingMode
ReCalculateParents
--> Reset
CalculateLODDistances
UsingUltraShader
--> SetupStaticMaterial
ApplyAll
FindTreeUsingFastShader
SetupHalfSrqTransition
CalculateLODDistances
UsingUltraShader
UsingUltraShader
--> Reset
CalculateLODDistances
UsingUltraShader
--> SetupStaticMaterial
CalculateLODDistances
UsingUltraShader

..and then it loops through all the trees again. It appears that all of this is taking place within the same Update frame.

Another significant update:


I just inadvertedly checked my log file again, and found that the endless loop looks different when running the build version:


CalculateLODDistances
UsingUltraShader
CalculateLODDistances
UsingUltraShader
CalculateLODDistances
UsingUltraShader
CalculateLODDistances
UsingUltraShader
CalculateLODDistances
UsingUltraShader
CalculateLODDistances
UsingUltraShader
CalculateLODDistances
UsingUltraShader
CalculateLODDistances
UsingUltraShader
CalculateLODDistances
UsingUltraShader
CalculateLODDistances
UsingUltraShader
CalculateLODDistances
UsingUltraShader
(.....)

It appears that it's not even doing anything in _LushLODTree, but the manager is quite busy calculating LOD distances.

All trees have been spawned dynamically during the Start() frame, there were no trees before that.


Just to clarify that I did it correctly: I added a LushLOD tree to the GameObject that holds all the spawned trees, then I created a manager via that tree and setup the manager with the parent GameObject as parent and deleted the one LushLOD tree I had inserted. Then I changed my tree spawner to spawn the same LushLOD tree prefab, instead of the old tree model.


Also, I completely forgot to test a build version so I did, and the same thing happens (it ate so much of my pc's memory that I had to restart manually, in fact). So I guess we can confirm that it's not caused by editor code.

Update: it goes through the repeating part for each tree, then a new frame, and it calls ApplyAll() and loops through each tree again. It takes an extremely long time; after several minutes it only gets through around 30 frames. And this is with a total of 256 trees in the scene.

Sorry for the delay, I work during weekdays so I only really have time for game development during weekends.


I took a different approach: I modified each method inside _LushLODTreesManager and _LushLODTree, so that when a method is executed, its name is written to an external log file. The method names in _LushLODTree are prepended by "-->", so they can be distinguished from the manager's methods. So I hit Play and let the game hang for a few minutes. This is what I found:


Start
SetupHalfSrqTransition
CalculateLODDistances
UsingUltraShader
UsingUltraShader
Update
--> Start
--> CreateTreeManager
--> LoadSaneStartingSettings
GetHighQualityShadowCastingMode
GetBillboardShadowCastingMode
ReCalculateParents
--> Reset
CalculateLODDistances
UsingUltraShader
--> SetupStaticMaterial
ApplyAll
FindTreeUsingFastShader
SetupHalfSrqTransition
CalculateLODDistances
UsingUltraShader
UsingUltraShader
--> Reset
CalculateLODDistances
UsingUltraShader
--> SetupStaticMaterial
CalculateLODDistances
UsingUltraShader
--> DoShaderUpdate
--> GetBillboardLeavesShader
--> GetBillboardLeavesFarShader
    >>> The following bit repeats forever: <<<
UsingUltraShader
--> GetLeavesShader
UsingUltraShader
--> GetLeavesShader
UsingUltraShader
--> GetBarkShader
UsingUltraShader
--> GetBarkShader
--> DoShaderUpdate
--> SetupStaticMaterial
--> GetBillboardLeavesShader
--> GetBillboardLeavesFarShader

The problems begin during the first Update frame, which makes sense as that's right after the trees are added (I'm guessing that the LushLOD scripts are being executed before my tree instantiator script).