Skip to content

Commit

Permalink
Remove FindObjectOfType
Browse files Browse the repository at this point in the history
  • Loading branch information
szylis committed Feb 26, 2024
1 parent 9519b0b commit bfa79b6
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 60 deletions.
108 changes: 60 additions & 48 deletions Assets/AWSIM/Scenes/Main/AutowareSimulation.unity
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 1519.6069, g: 1883.9946, b: 2490.9849, a: 1}
m_IndirectSpecularColor: {r: 1520.0924, g: 1884.674, b: 2491.8425, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
Expand Down Expand Up @@ -536,6 +536,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
trafficManager: {fileID: 723377035}
egoTransform: {fileID: 7808269042169720464}
timeSourceSelector: {fileID: 1259688278}
commandLineConfigParam: --json_path
useJsonConfig: 0
jsonPath:
Expand Down Expand Up @@ -3239,6 +3240,17 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 830ab73cebda3db4580ebd3ece935931, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &1259688278 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 3077555317673241940, guid: 27181f17b3e1bb607a4b8fcb8a827e0f, type: 3}
m_PrefabInstance: {fileID: 1575276244}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0dde57169074a9c5c9780c80294b4427, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &1381324630
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -4530,6 +4542,53 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 23c1ce4fb46143f46bc5cb5224c934f6, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Version: 7
m_ObsoleteRenderingPath: 0
m_ObsoleteFrameSettings:
overrides: 0
enableShadow: 0
enableContactShadows: 0
enableShadowMask: 0
enableSSR: 0
enableSSAO: 0
enableSubsurfaceScattering: 0
enableTransmission: 0
enableAtmosphericScattering: 0
enableVolumetrics: 0
enableReprojectionForVolumetrics: 0
enableLightLayers: 0
enableExposureControl: 1
diffuseGlobalDimmer: 0
specularGlobalDimmer: 0
shaderLitMode: 0
enableDepthPrepassWithDeferredRendering: 0
enableTransparentPrepass: 0
enableMotionVectors: 0
enableObjectMotionVectors: 0
enableDecals: 0
enableRoughRefraction: 0
enableTransparentPostpass: 0
enableDistortion: 0
enablePostprocess: 0
enableOpaqueObjects: 0
enableTransparentObjects: 0
enableRealtimePlanarReflection: 0
enableMSAA: 0
enableAsyncCompute: 0
runLightListAsync: 0
runSSRAsync: 0
runSSAOAsync: 0
runContactShadowsAsync: 0
runVolumeVoxelizationAsync: 0
lightLoopSettings:
overrides: 0
enableDeferredTileAndCluster: 0
enableComputeLightEvaluation: 0
enableComputeLightVariants: 0
enableComputeMaterialVariants: 0
enableFptlForForwardOpaque: 0
enableBigTilePrepass: 0
isFptlEnabled: 0
clearColorMode: 0
backgroundColorHDR: {r: 0.025, g: 0.07, b: 0.19, a: 0}
clearDepth: 1
Expand Down Expand Up @@ -4585,53 +4644,6 @@ MonoBehaviour:
data1: 0
data2: 0
defaultFrameSettings: 0
m_Version: 7
m_ObsoleteRenderingPath: 0
m_ObsoleteFrameSettings:
overrides: 0
enableShadow: 0
enableContactShadows: 0
enableShadowMask: 0
enableSSR: 0
enableSSAO: 0
enableSubsurfaceScattering: 0
enableTransmission: 0
enableAtmosphericScattering: 0
enableVolumetrics: 0
enableReprojectionForVolumetrics: 0
enableLightLayers: 0
enableExposureControl: 1
diffuseGlobalDimmer: 0
specularGlobalDimmer: 0
shaderLitMode: 0
enableDepthPrepassWithDeferredRendering: 0
enableTransparentPrepass: 0
enableMotionVectors: 0
enableObjectMotionVectors: 0
enableDecals: 0
enableRoughRefraction: 0
enableTransparentPostpass: 0
enableDistortion: 0
enablePostprocess: 0
enableOpaqueObjects: 0
enableTransparentObjects: 0
enableRealtimePlanarReflection: 0
enableMSAA: 0
enableAsyncCompute: 0
runLightListAsync: 0
runSSRAsync: 0
runSSAOAsync: 0
runContactShadowsAsync: 0
runVolumeVoxelizationAsync: 0
lightLoopSettings:
overrides: 0
enableDeferredTileAndCluster: 0
enableComputeLightEvaluation: 0
enableComputeLightVariants: 0
enableComputeMaterialVariants: 0
enableFptlForForwardOpaque: 0
enableBigTilePrepass: 0
isFptlEnabled: 0
--- !u!81 &2122627085
AudioListener:
m_ObjectHideFlags: 0
Expand Down
18 changes: 6 additions & 12 deletions Assets/AWSIM/Scenes/Main/AutowareSimulation/AutowareSimulation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class AutowareSimulation : MonoBehaviour
{
[SerializeField] TrafficManager trafficManager;
[SerializeField] Transform egoTransform;
private TimeSourceSelector timeSourceSelector;
[SerializeField] TimeSourceSelector timeSourceSelector;

[Header("Player Config")]
[SerializeField] string commandLineConfigParam = "--json_path";
Expand Down Expand Up @@ -42,7 +42,11 @@ public class Configuration

void Awake()
{
CollectComponents();
// check if time source selector is present
if(timeSourceSelector == null)
{
Debug.LogWarning("TimeSource: There is no TimeSourceSelector object assigned in the inspector. The default time source will be used.");
}

#if !UNITY_EDITOR
// initialize
Expand Down Expand Up @@ -70,15 +74,5 @@ void Awake()
timeSourceSelector?.SetType(config.TimeSource);
}
}

void CollectComponents()
{
// get time source selector
timeSourceSelector = FindObjectOfType<TimeSourceSelector>();
if(timeSourceSelector == null)
{
Debug.LogWarning("TimeSource: There is no TimeSourceSelector object in the active scene. The default time source will be used.");
}
}
}
}

0 comments on commit bfa79b6

Please sign in to comment.