Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit 4c16597

Browse files
committed
Cache m_Target camera component to avoid repeatedly calling GetComponent<>()
1 parent f00c98f commit 4c16597

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

PostProcessing/Editor/PostProcessLayerEditor.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ sealed class PostProcessLayerEditor : BaseEditor<PostProcessLayer>
3838

3939
Dictionary<PostProcessEvent, ReorderableList> m_CustomLists;
4040

41+
#if UNITY_2017_3_OR_NEWER
42+
Camera m_TargetCameraComponent;
43+
#endif
44+
4145
static GUIContent[] s_AntialiasingMethodNames =
4246
{
4347
new GUIContent("No Anti-aliasing"),
@@ -75,6 +79,10 @@ void OnEnable()
7579

7680
m_ShowToolkit = serializedObject.FindProperty("m_ShowToolkit");
7781
m_ShowCustomSorter = serializedObject.FindProperty("m_ShowCustomSorter");
82+
83+
#if UNITY_2017_3_OR_NEWER
84+
m_TargetCameraComponent = m_Target.GetComponent<Camera>();
85+
#endif
7886
}
7987

8088
void OnDisable()
@@ -162,9 +170,10 @@ void DoAntialiasing()
162170
if (RuntimeUtilities.isSinglePassStereoSelected)
163171
EditorGUILayout.HelpBox("TAA requires Unity 2017.3+ for Single-pass stereo rendering support.", MessageType.Warning);
164172
#endif
165-
var camera = m_Target.GetComponent<Camera>();
166-
if (camera.allowDynamicResolution)
173+
#if UNITY_2017_3_OR_NEWER
174+
if (m_TargetCameraComponent != null && m_TargetCameraComponent.allowDynamicResolution)
167175
EditorGUILayout.HelpBox("TAA is not supported with Dynamic Resolution.", MessageType.Warning);
176+
#endif
168177

169178
EditorGUILayout.PropertyField(m_TaaJitterSpread);
170179
EditorGUILayout.PropertyField(m_TaaStationaryBlending);

0 commit comments

Comments
 (0)