public void RemoveDestroyedObjectsTest() { var go = new GameObject(); var list = new List <GameObject> { go }; UnityObjectUtils.Destroy(go); UnityObjectUtils.RemoveDestroyedObjects(list); Assert.Zero(list.Count); }
static void HandleLightScaling(List <Light> lights, float scaleFactor) { UnityObjectUtils.RemoveDestroyedObjects(lights); if (lights.Count > 0) { Undo.RecordObjects(lights.ToArray <UnityObject>(), "WorldScale"); foreach (var light in lights) { // Directional lights internally normalize their range // so the effect of the scaling only is visible when scaling and produces strange results. if (light.type != LightType.Directional) { light.range *= scaleFactor; } light.shadowBias *= scaleFactor; } } }
static void HandleAudioScaling(List <AudioSource> audioSources, List <AudioReverbZone> reverbZones, float scaleFactor) { UnityObjectUtils.RemoveDestroyedObjects(audioSources); if (audioSources.Count > 0) { Undo.RecordObjects(audioSources.ToArray <UnityObject>(), "WorldScale"); foreach (var source in audioSources) { source.minDistance *= scaleFactor; source.maxDistance *= scaleFactor; } } UnityObjectUtils.RemoveDestroyedObjects(reverbZones); if (reverbZones.Count > 0) { Undo.RecordObjects(reverbZones.ToArray <UnityObject>(), "WorldScale"); foreach (var zone in reverbZones) { zone.minDistance *= scaleFactor; zone.maxDistance *= scaleFactor; } } }