💦 CREATE AND FUCK YOUR OWN AI CUMSLUT 🔥 TRY NOW ♥
Create AI Cumsluts 💦
AddLODToChildren.cs 1.2 KB
March 7, 2023

Auto LOD assign for distance culling script!

You can use this by assigning the script to the parent object and it should automatically add the LOD component and mesh renderer component to each child object.

Remember to delete it after assigning it to the parent object!!
This should be somewhat useful for quick and dirty distance culling.

Comments (1)

R
Rollthered · March 7, 2023

using UnityEngine; #if UNITY_EDITOR using UnityEditor; #endif [ExecuteInEditMode] public class AddLODToChildren : MonoBehaviour { void Awake() { #if UNITY_EDITOR if (!EditorApplication.isPlaying) { AddLODComponents(); } #else AddLODComponents(); #endif } void AddLODComponents() { Transform[] children = GetComponentsInChildren(true); foreach (Transform child in children) { if (child == transform) { continue; } if (child.GetComponent() == null) { Undo.AddComponent(child.gameObject); MeshRenderer meshRenderer = child.GetComponent(); if (meshRenderer != null) { LODGroup lodGroup = child.GetComponent(); LOD[] lods = new LOD[1]; lods[0] = new LOD(0.01f, new Renderer[] { meshRenderer }); lodGroup.SetLODs(lods); lodGroup.RecalculateBounds(); } } } } }