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.
  2. Dismiss Notice

Question Can't add script error

Discussion in 'Scripting' started by wsc34, Apr 13, 2021.

  1. wsc34

    wsc34

    Joined:
    Dec 26, 2020
    Posts:
    18
    I closed the unity editor and do something else and restart it after 5 min and the "Can't add script" error occur for all of my code.

    When I looked at the game object the error message is shown as below.

    I checked that the script is indeed having the correct name and has no compile error.

    I am not sure what is causing the problem and I tried "Reimport All" without any luck. Now I cannot even attach a newly created empty script to any game object.

    I declined the auto-update that prompted half an hour ago would it be a possible reason?
     
  2. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,073
    are there any errors in the console?
     
  3. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,138
    If you have any compiler errors, you'll be unable to add scripts and you're see the Associated script can't be loaded message. I just noticed you said no compile errors(, but it can be a compile error in any script. Not just this one. Just when you load up the project, errors at that point can create this issue.
     
    Last edited: Apr 13, 2021
  4. wsc34

    wsc34

    Joined:
    Dec 26, 2020
    Posts:
    18
    I checked that there is no compile error in the code, does it include other script?
     
    Last edited: Apr 13, 2021
  5. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,138
    That's what I said...if you have any compile errors in any script...
     
  6. wsc34

    wsc34

    Joined:
    Dec 26, 2020
    Posts:
    18
    Thank you so much, the problem is resolved.