浏览代码

fixed ForgroundObjectPlacementRandomizer GameObject cache transform parent

/main
Steven Leal 4 年前
当前提交
85c67ea8
共有 2 个文件被更改,包括 10 次插入10 次删除
  1. 15
      com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Randomizers/BackgroundObjectPlacementRandomizer.cs
  2. 5
      com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Randomizers/ForegroundObjectPlacementRandomizer.cs

15
com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Randomizers/BackgroundObjectPlacementRandomizer.cs


/// </summary>
public GameObjectParameter prefabs;
GameObject container;
GameObjectOneWayCache gameObjectOneWayCache;
GameObject m_Container;
GameObjectOneWayCache m_GameObjectOneWayCache;
container = new GameObject("BackgroundContainer");
container.transform.parent = scenario.transform;
gameObjectOneWayCache = new GameObjectOneWayCache(container.transform, prefabs.categories.Select((element) => element.Item1).ToArray());
m_Container = new GameObject("BackgroundContainer");
m_Container.transform.parent = scenario.transform;
m_GameObjectOneWayCache = new GameObjectOneWayCache(
m_Container.transform, prefabs.categories.Select((element) => element.Item1).ToArray());
}
/// <summary>

var offset = new Vector3(placementArea.x, placementArea.y, 0f) * -0.5f;
foreach (var sample in placementSamples)
{
var instance = gameObjectOneWayCache.GetOrInstantiate(prefabs.Sample());
var instance = m_GameObjectOneWayCache.GetOrInstantiate(prefabs.Sample());
instance.transform.position = new Vector3(sample.x, sample.y, separationDistance * i + depth) + offset;
}
placementSamples.Dispose();

/// </summary>
protected override void OnIterationEnd()
{
gameObjectOneWayCache.ResetAllObjects();
m_GameObjectOneWayCache.ResetAllObjects();
}
}
}

5
com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Randomizers/ForegroundObjectPlacementRandomizer.cs


protected override void OnCreate()
{
m_Container = new GameObject("Foreground Objects");
var scenarioTransform = scenario.transform;
m_Container.transform.parent = scenarioTransform;
m_Container.transform.parent = scenario.transform;
scenarioTransform, prefabs.categories.Select(element => element.Item1).ToArray());
m_Container.transform, prefabs.categories.Select(element => element.Item1).ToArray());
}
/// <summary>

正在加载...
取消
保存