浏览代码

randomizers now reference the current scenario through the static activeScenario property

/main
Steven Leal 4 年前
当前提交
9ec4a981
共有 2 个文件被更改,包括 2 次插入15 次删除
  1. 14
      com.unity.perception/Runtime/Randomization/Randomizers/Randomizer.cs
  2. 3
      com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs

14
com.unity.perception/Runtime/Randomization/Randomizers/Randomizer.cs


public abstract class Randomizer
{
bool m_PreviouslyEnabled;
// ReSharper disable once InconsistentNaming
ScenarioBase m_Scenario;
// ReSharper disable once InconsistentNaming
RandomizerTagManager m_TagManager;
[HideInInspector, SerializeField] internal bool collapsed;

/// <summary>
/// Returns the scenario containing this Randomizer
/// </summary>
public ScenarioBase scenario => m_Scenario;
public ScenarioBase scenario => ScenarioBase.activeScenario;
public RandomizerTagManager tagManager => m_TagManager;
public RandomizerTagManager tagManager => scenario.tagManager;
internal IEnumerable<Parameter> parameters
{

/// OnUpdate is executed every frame for enabled Randomizers
/// </summary>
protected virtual void OnUpdate() { }
internal void Initialize(ScenarioBase parentScenario, RandomizerTagManager parentTagManager)
{
m_Scenario = parentScenario;
m_TagManager = parentTagManager;
}
internal virtual void Create()
{

3
com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs


activeScenario = this;
OnAwake();
foreach (var randomizer in m_Randomizers)
randomizer.Initialize(this, tagManager);
foreach (var randomizer in m_Randomizers)
randomizer.Create();
ValidateParameters();

$"Two Randomizers of the same type ({randomizerType.Name}) cannot both be active simultaneously");
var newRandomizer = (Randomizer)Activator.CreateInstance(randomizerType);
m_Randomizers.Add(newRandomizer);
newRandomizer.Initialize(this, tagManager);
newRandomizer.Create();
return newRandomizer;
}

正在加载...
取消
保存