Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved Add Cull to LOD Group via editor script

Discussion in 'Scripting' started by Alex_lemes, Mar 1, 2021.

  1. Alex_lemes

    Alex_lemes

    Joined:
    Nov 14, 2014
    Posts:
    8
    Hello,

    I'm having some troubles with the LOD Grouping API from Unity. I've made an editor tool to add a LOD group to my object & I have the two levels I wanted, but when you assign the LODs via LODGroup.SetLODs() it removes the CULL level & so far I cannot see how to re-add it, tried some hacky ways to get it on but nothing...Am I blind or something? :S

    Does anyone have a solution?

    Much appreciated!
     
  2. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201
    How are you setting them? I can't seem to duplicate what you're describing.

    Code (csharp):
    1.  
    2. private void Start()
    3. {
    4.    LODGroup group = GetComponent<LODGroup>();
    5.    LOD[] lods = new LOD[2];
    6.    lods[0] = new LOD(0.50f, null);
    7.    lods[1] = new LOD(0.25f, null);
    8.  
    9.    group.SetLODs(lods);
    10.    group.RecalculateBounds();
    11. }
    12.  
    capture.jpg
     
    LazloBonin and tmonestudio like this.
  3. Alex_lemes

    Alex_lemes

    Joined:
    Nov 14, 2014
    Posts:
    8
    Ok, so I found the prob & fixed it thanks for helping! I tried the NULL before but had some error and now I just realised that the first LOD level is always there and the ones in the array are extra...
     
    GroZZleR likes this.