static void RemRendererLMInfo() { Renderer[] renderers = FindObjectsOfType <Renderer>(); for (int i = 0; i < renderers.Length; i++) { Renderer renderer = renderers[i]; RendererLMInfo rendererLMInfo = renderer.gameObject.GetComponent <RendererLMInfo>(); if (rendererLMInfo != null) { GameObject.DestroyImmediate(rendererLMInfo); } } }
static void AddRendererLMInfo() { Renderer[] renderers = FindObjectsOfType <Renderer>(); for (int i = 0; i < renderers.Length; i++) { Renderer renderer = renderers[i]; RendererLMInfo rendererLMInfo = renderer.gameObject.GetComponent <RendererLMInfo>(); if (rendererLMInfo != null) { GameObject.DestroyImmediate(rendererLMInfo); } if (renderer.lightmapIndex >= 0 && renderer.lightmapIndex != 655535) { rendererLMInfo = renderer.gameObject.AddComponent <RendererLMInfo>(); rendererLMInfo.lightmapIndex = renderer.lightmapIndex; rendererLMInfo.lightmapScaleOffset = renderer.lightmapScaleOffset; } } }