From 31e1650d57ad6838a69116d37a46a2b0ebd9ecee Mon Sep 17 00:00:00 2001 From: Jon Hogins Date: Thu, 22 Apr 2021 15:09:19 -0700 Subject: [PATCH] Fixing lighting on foreground objects. Also making it so that local assets in the ForegroundObjectPlacementRandomizer continue to work for local testing --- .../ForegroundObjectPlacementRandomizer.cs | 11 +++++++++++ SynthDet/Assets/Scripts/Runtime/SynthDetScenario.cs | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/SynthDet/Assets/Scripts/Runtime/Randomizers/ForegroundObjectPlacementRandomizer.cs b/SynthDet/Assets/Scripts/Runtime/Randomizers/ForegroundObjectPlacementRandomizer.cs index 6d72f2ef..b341163c 100644 --- a/SynthDet/Assets/Scripts/Runtime/Randomizers/ForegroundObjectPlacementRandomizer.cs +++ b/SynthDet/Assets/Scripts/Runtime/Randomizers/ForegroundObjectPlacementRandomizer.cs @@ -61,12 +61,23 @@ namespace SynthDet.Randomizers foreach (var prefab in prefabs) { + ConfigureLayerRecursive(prefab); ConfigureRandomizerTags(prefab); } m_GameObjectOneWayCache = new GameObjectOneWayCache(m_Container.transform, prefabs); } + private static void ConfigureLayerRecursive(GameObject prefab) + { + prefab.layer = LayerMask.NameToLayer("Foreground"); + for (int i = 0; i < prefab.transform.childCount; i++) + { + var child = prefab.transform.GetChild(i).gameObject; + ConfigureLayerRecursive(child); + } + } + /// /// Generates a foreground layer of objects at the start of each scenario iteration /// diff --git a/SynthDet/Assets/Scripts/Runtime/SynthDetScenario.cs b/SynthDet/Assets/Scripts/Runtime/SynthDetScenario.cs index d4cf26f9..1a62ae5c 100644 --- a/SynthDet/Assets/Scripts/Runtime/SynthDetScenario.cs +++ b/SynthDet/Assets/Scripts/Runtime/SynthDetScenario.cs @@ -115,7 +115,7 @@ namespace SynthDet.Scenarios // Inject the loaded prefabs into the ForegroundObjectPlacementRandomizer var randomizer = GetRandomizer(); - randomizer.prefabs = prefabsList.ToArray(); + randomizer.prefabs = randomizer.prefabs.Concat(prefabsList).ToArray(); } void ConfigureLabeling(GameObject gObj)