LOD's and OnWillRenderObject

Hi guys

Short and sweet: if one has a model with three LOD’s, where to put a script that handles OnWillRenderObject?

The prefab hierarchy looks like this:

Model

  • LOD0 - Script lives here
  • LOD1
  • LOD2

As long as the model is near, the script gets OnWillRenderObject. But when the object is far, LOD1 and 2 start rendering, and this method is no longer called.

So what to do?

  • I can’t put the script on all three LOD’s. That’s silly
  • I can’t put the script on the prefab root, there is no render geometry there, so OnWillRenderObject never gets called.

I haven’t had to deal with this myself but my naive solution would be this:

Add “helper” scripts to each LOD. These would only have OnWillRenderObject in them and they would call a function in a script attached to your parent object.

There may be other ways: Who is the caller and can it be extended/subclassed? Can you move your code into another function that would give the same results?