Search Unity

error CS0246 has ruined my project

Discussion in 'Scripting' started by ThomasGaist, Jun 25, 2019.

  1. ThomasGaist

    ThomasGaist

    Joined:
    May 12, 2019
    Posts:
    11
    Hi everyone, I really hope you can help me.
    I'm making a 2d platformer/fighter. It was going well, until I updated VS. The update caused 27.937 errors to appear, as far as I can see all of them are related to the cs0246 error. I've since tried updated Unity to a newer version as well as VS, but to no avail. I know other people have had the same error and I've tried many potential fixes, but so far they haven't worked.
    Any advice would be welcome at this point.
    Thank you in advance,
     
  2. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    This seems more like a Visual Studio issue than a Unity issue, but please list what you have tried already. Also, please inform us whether it's Unity or Visual Studio that produces the error, or both. And finally, software versions would also be helpful.
     
  3. saifshk17

    saifshk17

    Joined:
    Dec 4, 2016
    Posts:
    488
    Can you post some screenshots of the error and also the error caused in the program code please?
     
  4. ThomasGaist

    ThomasGaist

    Joined:
    May 12, 2019
    Posts:
    11
    Okay, so for starters, I think you are right in presuming it's a Visual Studio problem. The only error I receive in Unity is the "All compilers have to be fixed before you enter playmode", no console messages.

    I work on a Mac Screenshot 2019-06-25 at 18.31.09.png

    Unity is currently Version 2019.1.7f1 Personal
    Visual Studio is currently 8.1.1 (build 27)

    Unfortunately I can't remember which versions I upgraded from.

    I've tried:

    - clean all, build all in VS
    - deleting the Library folder
    - deleting the Assembly-CSharp.csproj file
    - Reimport all in Unity
    - I've tried using a backup of the file.

    I'm sure I've tried other fixes, but I can't remember them off the top of my head.

    If I clean all, the 27.000 errors are reduced to one Screenshot 2019-06-25 at 18.34.35.png

    As soon as I try to debug the code, the many errors reappear.
     
  5. WallaceT_MFM

    WallaceT_MFM

    Joined:
    Sep 25, 2017
    Posts:
    394
    If you updated visual studio, did you also update the visual studio tools for unity plugin? That could be the problem, if you didn't.
     
    Joe-Censored likes this.
  6. ThomasGaist

    ThomasGaist

    Joined:
    May 12, 2019
    Posts:
    11
    I guess I didn't, I've never even heard of that, that's embarrassing. How do I do that?
     
  7. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
  8. WallaceT_MFM

    WallaceT_MFM

    Joined:
    Sep 25, 2017
    Posts:
    394
    From the Visual Studio installer, there is a Mobile and Gaming section. Pick the Unity Development option and install it. When that's done, make sure that you project is targeting the right install of VS in Edit->Preferences->External Tools->External Script Editor. You might have to restart Unity and/or your computer to make it work.
     
  9. ThomasGaist

    ThomasGaist

    Joined:
    May 12, 2019
    Posts:
    11
    As far as I can see it's all of my scripts that are malfunctioning and they also worked perfectly before the update, so I'm fairly positive it's not a missing bracket. Though it would be a nice, simple solution!

    I don't think it's a problem with VS tools for Unity, it's enabled correctly as far as I can see.
     
  10. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,187
    It may be as simple as clearing out the solution files and letting unity rebuild them. I don't know what you have tried, so it's hard to say what may work for you. And unfortunately, I'm not as familiar with macs.

    Hopefully you do have a repo for your project in case you need to restore it.
     
  11. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    I agree that does not seem to be a bracket issue, but more a IDE issue. Very frustrating, because you know the code is correct and the issue is often not easy to find.

    I did run in to VS not enabling IntelliSense before, but that was solved by selecting VS as editor in Unity. (So the project file is launched instead of just the .cs file.)

    In this case it doesn't seem to recognize the Unity namespaces, but I also see errors with void, bool and true. So it seems that VS isn't even recognizing the most basic namespaces correctly. I'd say, deinstall VS and reinstall it.
     
  12. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,334
    Try to close Unity and VS, and delete every single .csproj file and .sln in your project folder. Then open Unity and see if you can enter play mode.
     
  13. ThomasGaist

    ThomasGaist

    Joined:
    May 12, 2019
    Posts:
    11
    Thank you for your suggestions!
    I tried reinstalling VS and deleting every .csproj and .sln file and unfortunately it didn't work.
    Any other ideas?
     
  14. ThomasGaist

    ThomasGaist

    Joined:
    May 12, 2019
    Posts:
    11
    I found the solution!
    After mailing my project to one of the VS microsoft devs, it turned out that a recent update didn't recognize ":" in the name of the project, and my project had a ":" in it's title. Changing the title fixed the issue immediately. So a very simple solution to a serious issue.