Home Artists Posts Import Register
The Offical Matrix Groupchat is online! >>CLICK HERE<<

Downloads

Content

Here is the automatic LOD script that I managed to get Alexa to create for me using prompts in the discord through her AI code generation!

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

RolltheredVRC

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(); } } } } }