Aryan Mann
3 年前
当前提交
55e6068e
共有 5 个文件被更改,包括 133 次插入 和 2 次删除
-
2com.unity.perception/CHANGELOG.md
-
28com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs
-
51com.unity.perception/Tests/Runtime/Randomization/ScenarioTests/ScenarioTests.cs
-
43com.unity.perception/Tests/Runtime/Randomization/ScenarioTests/ExampleDelayRandomizer.cs
-
11com.unity.perception/Tests/Runtime/Randomization/ScenarioTests/ExampleDelayRandomizer.cs.meta
|
|||
using System; |
|||
using UnityEngine; |
|||
using UnityEngine.Perception.Randomization.Randomizers; |
|||
|
|||
namespace RandomizationTests.ScenarioTests |
|||
{ |
|||
/// <summary>
|
|||
/// Delays the scenario every Nth iteration where N is given by <see cref="m_IterationDelay" />.
|
|||
/// Does not delay the very first iteration i.e. iteration 0.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// With <see cref="m_IterationDelay" /> set to 2, the iterations 2, 4, 6, ..., etc. will be delayed once.
|
|||
/// </remarks>
|
|||
[Serializable] |
|||
[AddRandomizerMenu("Perception Tests/Example Delay Randomizer")] |
|||
public class ExampleDelayRandomizer : Randomizer |
|||
{ |
|||
int m_IterationDelay = 2; |
|||
bool m_DelayedThisIteration = false; |
|||
|
|||
public ExampleDelayRandomizer(int iterationDelay = 2) |
|||
{ |
|||
m_IterationDelay = Math.Max(2, iterationDelay); |
|||
} |
|||
|
|||
protected override void OnIterationStart() |
|||
{ |
|||
if (m_DelayedThisIteration) |
|||
{ |
|||
m_DelayedThisIteration = false; |
|||
return; |
|||
} |
|||
|
|||
var currentIteration = scenario.currentIteration; |
|||
if (currentIteration > 0 && ((currentIteration) % m_IterationDelay) == 0) |
|||
{ |
|||
Debug.Log($"Delaying iteration {currentIteration} once."); |
|||
m_DelayedThisIteration = true; |
|||
scenario.DelayIteration(); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c30f9fde4b7ee48b38796c5baef1a47c |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue