Search Unity

LOD's and OnWillRenderObject

Discussion in 'Editor & General Support' started by psantoki, Apr 24, 2013.

  1. psantoki

    psantoki

    Joined:
    Oct 24, 2012
    Posts:
    17
    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.
     
  2. rapidfirestudio

    rapidfirestudio

    Joined:
    Jan 31, 2013
    Posts:
    73
    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?