|
|
|
|
|
|
using System; |
|
|
|
using UnityEngine.Perception.Randomization.Parameters; |
|
|
|
using UnityEngine.Perception.Randomization.Randomizers.SampleRandomizers.Tags; |
|
|
|
|
|
|
|
namespace UnityEngine.Perception.Randomization.Randomizers.SampleRandomizers |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// Randomizes the luminescence of lights tagged with a LightRandomizerTag
|
|
|
|
/// </summary>
|
|
|
|
[Serializable] |
|
|
|
[AddRandomizerMenu("Perception/Light Randomizer")] |
|
|
|
|
|
|
|
public class LightRandomizer : Randomizer |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// The range of random intensities to assign to target lights
|
|
|
|
/// </summary>
|
|
|
|
[Tooltip("The range of random intensities to assign to target lights.")] |
|
|
|
public FloatParameter lightIntensity; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Randomizes the colors of tagged objects at the start of each scenario iteration
|
|
|
|
/// </summary>
|
|
|
|
protected override void OnIterationStart() |
|
|
|
{ |
|
|
|
var tags = tagManager.Query<LightRandomizerTag>(); |
|
|
|
foreach (var tag in tags) |
|
|
|
{ |
|
|
|
var light = tag.GetComponent<Light>(); |
|
|
|
light.intensity = lightIntensity.Sample(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |