Adds a LOD Group to everything you select and sets the children correctly.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
using UnityEngine; | |
public class LODTools | |
{ | |
[MenuItem("Tools/Add LOD Group/LOD 3")] | |
private static void AddGroup() | |
{ | |
var objects = Selection.objects; | |
foreach (var ob in objects) | |
{ | |
var go = (GameObject)ob; | |
var group = go.AddComponent<LODGroup>(); | |
var lods = new LOD[go.transform.childCount]; | |
var transitions = new float[] { .6f, .3f, .1f, .01f }; | |
for (int i = 0; i < lods.Length; i++) | |
{ | |
lods[i] = new LOD(transitions[i], go.transform.GetChild(i).GetComponents<Renderer>()); | |
} | |
group.SetLODs(lods); | |
Undo.AddComponent<LODGroup>(go); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment