浏览代码

added randomizer for lights (only intensities)

/feat-light-randomizer
Aryan Mann 3 年前
当前提交
ba22ebda
共有 4 个文件被更改,包括 65 次插入0 次删除
  1. 34
      com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Randomizers/LightRandomizer.cs
  2. 11
      com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Randomizers/LightRandomizer.cs.meta
  3. 9
      com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Tags/LightRandomizerTag.cs
  4. 11
      com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Tags/LightRandomizerTag.cs.meta

34
com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Randomizers/LightRandomizer.cs


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();
}
}
}
}

11
com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Randomizers/LightRandomizer.cs.meta


fileFormatVersion: 2
guid: ac600026acdac4ede995ae45ac213336
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

9
com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Tags/LightRandomizerTag.cs


namespace UnityEngine.Perception.Randomization.Randomizers.SampleRandomizers.Tags
{
/// <summary>
/// Used in conjunction with a LightRandomizer to vary the material color of GameObjects
/// </summary>
[RequireComponent(typeof(Light))]
[AddComponentMenu("Perception/RandomizerTags/Light Randomizer Tag")]
public class LightRandomizerTag : RandomizerTag { }
}

11
com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Tags/LightRandomizerTag.cs.meta


fileFormatVersion: 2
guid: 953eece94fa5644f69c5f7ceb5be1d27
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存