Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

HELP I HAVE 3 ERRORS WHEN BUILDING PROJECT

Discussion in 'Scripting' started by UltraRoyaleGameOwner, Jul 25, 2020.

  1. UltraRoyaleGameOwner

    UltraRoyaleGameOwner

    Joined:
    Apr 7, 2020
    Posts:
    26
    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 <feb76e495af340bfbdc89fc2ad1b8ae4>:0
    at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <feb76e495af340bfbdc89fc2ad1b8ae4>:0
    UnityEngine.GUIUtility:processEvent (int,intptr,bool&)

    Please help me Thanks
     
  2. WarmedxMints

    WarmedxMints

    Joined:
    Feb 6, 2017
    Posts:
    1,012
    The UnityEditor namespace is not available in a build so wrap your code in the UNITY_EDITOR preprocessor.

    Like so
    Code (CSharp):
    1.         public void QuitGame()
    2.         {
    3. #if UNITY_EDITOR
    4.             Debug.Log("You have quit the game");
    5.             if (UnityEditor.EditorApplication.isPlaying == true)
    6.             {
    7.                 UnityEditor.EditorApplication.isPlaying = false;
    8.             }
    9. #else
    10.             Application.Quit();
    11.    
    12. #endif
    13.         }
     
  3. UltraRoyaleGameOwner

    UltraRoyaleGameOwner

    Joined:
    Apr 7, 2020
    Posts:
    26
    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
     
  4. UltraRoyaleGameOwner

    UltraRoyaleGameOwner

    Joined:
    Apr 7, 2020
    Posts:
    26
    It change anything same errors but with EditorApplication
     
  5. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    3,364
    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.
     
unityunity