private void DrawEnvironmentInspector(BuildEnvironment environment,
                                              WorkerBuildConfiguration configurationForWorker)
        {
            var environmentName = environment.ToString();

            var environmentConfiguration =
                configurationForWorker.GetEnvironmentConfig(environment);

            var hash         = configurationForWorker.WorkerType.GetHashCode() ^ environment.GetHashCode() ^ typeof(FoldoutState).GetHashCode();
            var foldoutState = stateManager.GetStateObjectOrDefault <FoldoutState>(hash);

            if (foldoutState.Content == null || invalidateCachedContent > 0)
            {
                var builtTargets = string.Join(",",
                                               environmentConfiguration.BuildTargets.Where(t => t.Enabled).Select(t => t.Label));

                foldoutState.Content = new GUIContent($"{environmentName} Build Options ({builtTargets})");

                if (environmentConfiguration.BuildTargets.Any(IsBuildTargetError))
                {
                    foldoutState.Icon =
                        new GUIContent(EditorGUIUtility.IconContent(BuildConfigEditorStyle.BuiltInErrorIcon))
                    {
                        tooltip = "Missing build support for one or more build targets."
                    };
                }
                else if (environmentConfiguration.BuildTargets.Any(IsBuildTargetWarning))
                {
                    foldoutState.Icon =
                        new GUIContent(EditorGUIUtility.IconContent(BuildConfigEditorStyle.BuiltInWarningIcon))
                    {
                        tooltip = "Missing build support for one or more build targets."
                    };
                }
                else
                {
                    foldoutState.Icon = null;
                }
            }

            using (new GUILayout.HorizontalScope())
            {
                foldoutState.Expanded =
                    EditorGUILayout.Foldout(foldoutState.Expanded, foldoutState.Content, true);

                GUILayout.FlexibleSpace();
                if (foldoutState.Icon != null)
                {
                    GUILayout.Label(foldoutState.Icon);
                    GUILayout.Space(28);
                }
            }

            using (var check = new EditorGUI.ChangeCheckScope())
            {
                if (foldoutState.Expanded)
                {
                    DrawBuildTargets(environmentConfiguration, hash);
                }

                if (check.changed)
                {
                    // Re-evaluate heading.
                    foldoutState.Content = null;
                }
            }
        }