Repository: UnityTechnologies/open-project-1
File: UOP1_Project/Assets/Scripts/Editor/GameSceneEditor.cs (C#)

Code before:
    public override void OnInspectorGUI()
    {
        EditorGUILayout.LabelField("Scene information", headerLabelStyle);
        EditorGUILayout.Space();
        DrawScenePicker();
        DrawPropertiesExcluding(serializedObject, ExcludedProperties);
    }

    private void DrawScenePicker()
    {
        var sceneName = gameSceneTarget.sceneName;
        EditorGUI.BeginChangeCheck();
        var selectedScene = sceneList.ToList().IndexOf(sceneName);
        selectedScene = EditorGUILayout.Popup("Scene", selectedScene, sceneList);
        if (selectedScene > -1)
        {
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(target, "Changed selected scene");
                gameSceneTarget.sceneName = sceneList[selectedScene];
                MarkAllDirty();
            }
        }
        else
        {
            EditorGUILayout.HelpBox(noScenesWarning, MessageType.Warning);
        }
    }
    
    private void InitializeGuiStyles()
    {
        headerLabelStyle = new GUIStyle(EditorStyles.largeLabel)
        {
            fontStyle = FontStyle.Bold,
            fontSize = 18, fixedHeight = 70.0f
        };
    }

    /// <summary>
    /// Populates the scene picker with scenes included in the game's build index
    /// </summary>
    private void PopulateScenePicker()
    {
        var sceneCount = SceneManager.sceneCountInBuildSettings;
        sceneList = new string[sceneCount];
        for (int i = 0; i < sceneCount; i++)
        {
            sceneList[i] = Path.GetFileNameWithoutExtension(SceneUtility.GetScenePathByBuildIndex(i));
        }
    }
    

Review comment (suggestion):
There should be a call to `EditorGUI.EndChangeCheck();` here to avoid unbalanced calls when there is no scene selected yet

Code after:
    public override void OnInspectorGUI()
    {
        EditorGUILayout.LabelField("Scene information", headerLabelStyle);
        EditorGUILayout.Space();
        DrawScenePicker();
        DrawPropertiesExcluding(serializedObject, ExcludedProperties);
    }

    private void DrawScenePicker()
    {
        var sceneName = gameSceneTarget.sceneName;
        EditorGUI.BeginChangeCheck();
        var selectedScene = sceneList.ToList().IndexOf(sceneName);

        if (selectedScene < 0)
        {
            EditorGUILayout.HelpBox(noScenesWarning, MessageType.Warning);
        }
        
        selectedScene = EditorGUILayout.Popup("Scene", selectedScene, sceneList);
        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(target, "Changed selected scene");
            gameSceneTarget.sceneName = sceneList[selectedScene];
            MarkAllDirty();
        }
    }
    
    private void InitializeGuiStyles()
    {
        headerLabelStyle = new GUIStyle(EditorStyles.largeLabel)
        {
            fontStyle = FontStyle.Bold,
            fontSize = 18, fixedHeight = 70.0f
        };
    }

    /// <summary>
    /// Populates the scene picker with scenes included in the game's build index
    /// </summary>
    private void PopulateScenePicker()
    {
        var sceneCount = SceneManager.sceneCountInBuildSettings;
        sceneList = new string[sceneCount];
        for (int i = 0; i < sceneCount; i++)
        {
            sceneList[i] = Path.GetFileNameWithoutExtension(SceneUtility.GetScenePathByBuildIndex(i));
        }
    }
    
    /// <summary>