private void OnLODRendererVisibilityChanged(OutlineTargetLODRenderer lODRenderer, bool visibility) { GameObject lodGO = lODRenderer.gameObject; for (int i = 0; i < Targets.Length; i++) { if (Targets[i].renderer.gameObject == lodGO) { Targets[i].visible = visibility; break; } } //forceUpdate = true; DoUpdate(); }
void Start() { //myLayerOnStart = gameObject.layer; //outlineLayer = LayerMask.NameToLayer( "Outline" ); lodGroup = GetComponent <LODGroup>(); if (lodGroup) { lods = lodGroup.GetLODs(); for (int l = 0; l < lods.Length; l++) { LOD lod = lods[l]; for (int r = 0; r < lod.renderers.Length; r++) { if (lod.renderers[r]) { OutlineTargetLODRenderer visEvent = lod.renderers[r].gameObject.AddComponent <OutlineTargetLODRenderer>(); visEvent.OnVisibilityChanged.AddListener(OnLODRendererVisibilityChanged); OnLODRendererVisibilityChanged(visEvent, lod.renderers[r].isVisible); } } } } }