Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

[Newbie] Now getting build errors I didnt have before? any help would be appreciated!

Discussion in 'Getting Started' started by TriRealm, Dec 30, 2021.

  1. TriRealm

    TriRealm

    Joined:
    Dec 29, 2021
    Posts:
    3
    Newbie here, building a game in the long run but never had experience with unity, built a small test room for textures and also while I build a 3D Player Movement system, all went well and I had built the game 3 times beforehand.

    All I changed today was add a wooden floorboard texture and add 2 lines of code to the pausemenu

    The lines in the pause menu I added (Code below)


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.SceneManagement;
    5.  
    6. public class PauseMenu : MonoBehaviour
    7. {
    8.     public static bool isGamePaused = false;
    9.     [SerializeField] GameObject pauseMenu;
    10.  
    11.     // Update is called once per frame
    12.     void Update()
    13.     {
    14.         if (Input.GetKeyDown(KeyCode.Escape))
    15.         {
    16.             if (isGamePaused)
    17.             {
    18.                 ResumeGame();
    19.             }
    20.             else
    21.             {
    22.                 PauseGame();
    23.             }
    24.         }
    25.         if (Input.GetKeyDown(KeyCode.P))
    26.         {
    27.             Application.Quit();
    28.  
    29.             Debug.Log("Quit");
    30.         }
    31.     }
    32.     public void ResumeGame()
    33.     {
    34.         pauseMenu.SetActive(false);
    35.         Time.timeScale = 1f;
    36.         isGamePaused = false;
    37.         Cursor.visible = false;
    38.     }
    39.  
    40.     void PauseGame()
    41.     {
    42.         pauseMenu.SetActive(true);
    43.         Time.timeScale = 0f;
    44.         isGamePaused = true;
    45.         Cursor.visible = true;
    46.     }
    47.  
    48.     public void LoadMenu()
    49.     {
    50.         SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
    51.     }
    52.  
    53.     public void QuitGame()
    54.     {
    55.         Application.Quit();
    56.  
    57.         Debug.Log("Quit");
    58.     }
    59. }
    The lines added are "Cursor.visible = true;" and the false as well

    I tried removing this code and trying to build again and to no prevail it didnt solve my issue.

    The errors I having come in 4 parts though it says its only 2 errors, any help would be appreciated but even just help understanding and reading the errors would be nice!

    Error 1

    UnauthorizedAccessException: Access to the path "Library/BuildPlayerData\Editor" is denied.
    System.IO.Directory.Delete (System.String path) (at <695d1cc93cca45069c528c15c9fdd749>:0)
    System.IO.Directory.RecursiveDelete (System.String path) (at <695d1cc93cca45069c528c15c9fdd749>:0)
    System.IO.Directory.Delete (System.String path, System.Boolean recursive) (at <695d1cc93cca45069c528c15c9fdd749>:0)
    UnityEditor.VisualStudioIntegration.DirectoryIOProvider.Delete (System.String path, System.Boolean recursive) (at <7ac35247888b44f4a7e290f1f6bb33f3>:0)
    UnityEditor.Build.Player.BuildPlayerDataGenerator.CreateCleanFolder (System.Boolean isEditor) (at <7ac35247888b44f4a7e290f1f6bb33f3>:0)
    UnityEditor.Build.Player.BuildPlayerDataGenerator.GenerateForAssemblies (System.String[] assemblies, System.String[] searchPaths, UnityEditor.BuildTarget buildTarget, System.Boolean isEditor) (at <7ac35247888b44f4a7e290f1f6bb33f3>:0)
    UnityEditor.Build.Player.BuildPlayerDataGeneratorNativeInterface.GenerateForAssemblies (System.String[] assemblies, System.String[] searchPaths, UnityEditor.BuildTarget buildTarget, System.Boolean isEditor) (at <7ac35247888b44f4a7e290f1f6bb33f3>:0)
    UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()


    Error 2
    Error building player because script class layout might be incompatible between the editor and the player.


    Error 3

    Build completed with a result of 'Failed' in 0 seconds (91 ms)
    UnityEditor.BuildPlayerWindow:BuildPlayerAndRun ()


    Error 4

    UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors
    at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002ca] in <7ac35247888b44f4a7e290f1f6bb33f3>:0
    at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <7ac35247888b44f4a7e290f1f6bb33f3>:0
    UnityEditor.BuildPlayerWindow:BuildPlayerAndRun ()
     
  2. TriRealm

    TriRealm

    Joined:
    Dec 29, 2021
    Posts:
    3
    Deleting the 'player' and 'editor' folders in the project appears to have fixed!

    If anyone is able to understand why the error is occuring in the first place i'd love to know why