HELP I HAVE 3 ERRORS WHEN BUILDING PROJECT

Hello Community i have 4 errors and when i go to check them there not there and the stupid error log is lying

I did find one that does like EditorApplication and not sure how to fix it plz help

public void QuitGame()
{
Debug.Log(“You have quit the game”);
if (UnityEditor.EditorApplication.isPlaying == true)
{
UnityEditor.EditorApplication.isPlaying = false;
}
else
{
Application.Quit();
}
}
}

Another one is
Error building Player because scripts had compiler errors and there is no errors

Another one
Build completed with a result of ‘Failed’ in 3 seconds (3360 ms)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

and last one
UnityEditor.BuildPlayerWindow+BuildMethodException: 3 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002c6] in :0
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in :0
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Please help me Thanks

The UnityEditor namespace is not available in a build so wrap your code in the UNITY_EDITOR preprocessor.

Like so

        public void QuitGame()
        {
#if UNITY_EDITOR
            Debug.Log("You have quit the game");
            if (UnityEditor.EditorApplication.isPlaying == true)
            {
                UnityEditor.EditorApplication.isPlaying = false;
            }
#else
            Application.Quit();
    
#endif
        }

How do i check my player for compile errors when it says nothing i went through my player and no script has any errors and no unityeditor

It change anything same errors but with EditorApplication

As already mentioned, you cannot use any code from the “UnityEditor” namespace in a build. You probably have some “using UnityEditor.XYZ” or something in some of your scripts. Those scripts with can’t be used in your game, or you need to conditionally remove the UnityEditor using the same approach mentioned earlier, using #if UNITY_EDITOR.

Also, as you fix each error, be sure to restate what your new error is.