111
This commit is contained in:
72
Assets/ThirdParty/Tools/SetLodGroup/Editor/SetLodGroupEditor.cs
vendored
Normal file
72
Assets/ThirdParty/Tools/SetLodGroup/Editor/SetLodGroupEditor.cs
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
[CustomEditor(typeof(SetLodGroup))]
|
||||
public class SetLodGroupEditor : Editor
|
||||
{
|
||||
SetLodGroup inst;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
inst = (SetLodGroup)target;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
|
||||
//
|
||||
if(GUILayout.Button("SetLodGroup", GUILayout.Height(50)))
|
||||
{
|
||||
ASDASD();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void asdasdasda()
|
||||
{
|
||||
foreach (Transform t in inst.root.GetComponentInChildren<Transform>())
|
||||
{
|
||||
if (t.childCount > 0)
|
||||
{
|
||||
foreach (Transform tt in t.GetComponentInChildren<Transform>())
|
||||
{
|
||||
tt.gameObject.SetActive(true);
|
||||
tt.GetComponent<MeshRenderer>().enabled = false;
|
||||
}
|
||||
|
||||
t.GetChild(0).GetComponent<MeshRenderer>().enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ASDASD()
|
||||
{
|
||||
foreach (Transform t in inst.root.GetComponentInChildren<Transform>())
|
||||
{
|
||||
Debug.Log(t.name +" "+ t.childCount);
|
||||
if (t.childCount > 0)
|
||||
{
|
||||
if (t.gameObject.GetComponent<LODGroup>())
|
||||
{
|
||||
DestroyImmediate(t.gameObject.GetComponent<LODGroup>());
|
||||
}
|
||||
|
||||
//
|
||||
LODGroup lodGroup = t.gameObject.AddComponent<LODGroup>();
|
||||
|
||||
LOD[] lods = inst.lODGroup.GetLODs();
|
||||
for (int i = 0; i < lods.Length; ++i)
|
||||
{
|
||||
lods[i].renderers = new Renderer[] { t.GetChild(i).GetComponent<Renderer>() };
|
||||
}
|
||||
|
||||
lodGroup.SetLODs(lods);
|
||||
lodGroup.RecalculateBounds();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/Tools/SetLodGroup/Editor/SetLodGroupEditor.cs.meta
vendored
Normal file
11
Assets/ThirdParty/Tools/SetLodGroup/Editor/SetLodGroupEditor.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eac2d23c344733c42897d7e65b5cfc7d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user