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.

"Predefined type 'System.Object' is not defined or imported" what do I have to do?

Discussion in 'Scripting' started by Mahunreah, Nov 25, 2018.

  1. Mahunreah

    Mahunreah

    Joined:
    Mar 1, 2018
    Posts:
    10
    Hi :)
    I'm trying out the 2018.3.0b11 build of Unity. On my main machine, it runs as expected, but my laptop is acting up a bit in a curious way.

    I made a new project to follow along with a youtube tutorial. A few lines of code in, I realize that there are squiggly lines everywhere in my code:

    I've tried adding "using System" at the top of my code, but it didn't change anything. The error code seems to be CS0518, but this is the first time I've run into a problem like that and I don't really know how to solve it on my own. Yes, I have tried searching for a solution, but I didn't find any I understood =/

    Help would be appreciated :)
     
    scottyboy805 likes this.
  2. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,025
    That code's all correct, so it looks like there's an issue with your editor. Are there any errors in Unity's console?

    What code editor are you using?
     
  3. Mahunreah

    Mahunreah

    Joined:
    Mar 1, 2018
    Posts:
    10
    I'm Using Visual Studio 2017 :)

    There is one error I get while loading in VS, but I only got it from the third time loading the code onwards (I'll have to translate this, so the wording might be a bit off):

    "The C# project "Unity.PackageManagerUI.Editor" uses ".NETFramework, Version=v4.60", which is not installed on this machine. Choose one of the following options to continue:
    A) Change to .NET Framework 4.6.1. You can switch back to ".NETFramework, Version=v4.6" at a later date.
    B) Download the package for ".NETFramework, Version=v4.6". The project won't be changed.
    C) Don't load the project"

    I've tried "A", but nothing changes.
    I've tried "B", tried to install it but was told I already have a newer version of it installed so it won't bother installing it again.
    I've even tried "C", but it just brought me back to this error window.

    By now, I have uninstalled Unity and reinstalled it once more, but the error keeps showing up. Right now, I am re-installing Visual Studio in hopes of making the problem go away.
    Edit: Nope, didn't change anything, either :/

    Edit2: I don't get an error in Unity's console, but in Visual Studio's "list of errors". It's a few entries of "Code CS0518" and tons onf entries for (again, roughly translated) "The primary referal [...] could not be solved since it's using a higher version number than the one in the current target framework." and "The component [...], which has been refered to, could not be found"

     
    Last edited: Nov 25, 2018
  4. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,025
    This is a problem with the Visual Studio integration. There's a couple of things to check:
    - Did you install VS together with Unity, or did you already have it/install it separately?
    - Make sure you have the Unity plugin for VS installed.
    - Look through this thread to see if there's anything relevant. It's from the 2018.2 beta, so it's currently closed, but there could be good info there.

    If none of these work, you could try to use a different editor. Visual Studio Code is both free and well-liked by the community. Don't be confused by the name, it's a completely different product than Visual Studio.

    @sailro is the Visual Studio developer that I've seen in the forums that's been by recently, so he could have some insights about this.
     
    Zelek and Mahunreah like this.
  5. Mahunreah

    Mahunreah

    Joined:
    Mar 1, 2018
    Posts:
    10
    Thank you so very much!
    I had it installed from an older version of Unity, from the beginning of this year. I had kept it updated (at least I thought) and I've never had a problem like this before when changing Unity-versions, but looks like there was a small updating hickup along the way.
    I did have the Plugin for Unity installed, but re-installed it and behold:

    It's working again!

    This is the guide I followed to reinstall.

    Sadly, deactivating and reinstalling seems to have eaten my design-preferences for how certain parts of code should look like. Oh, well, redoing that is a small price to pay for a working program, I think.

    So, thanks again, you've helped me a ton :)!
     
    Zelek and Baste like this.
  6. SoniKSlayer

    SoniKSlayer

    Joined:
    Dec 25, 2018
    Posts:
    1
    I found another solution that took three steps and didn't involve a reinstall.

    1. Update Visual studio to latest version via Visual Studio Installer.
    2. Update .netframework via Visual Studio Installer. you can do this by pressing "Modify"
    3. Update the Unity integration Visual Studio Installer.

    in hindsight step 3 may be the solution but those were the exact steps that i took.

    Hope it helps
     
  7. phan72sm

    phan72sm

    Joined:
    Mar 25, 2019
    Posts:
    1
    Thanks SoniKSlayer. This worked for me. I updated Visual Studio to the latest version (which took hours and didn't solve the problem) but then I went into Modify...Individual components and just selected all the latest versions of the .NET framework. I'm sure there's a more elegant way of doing this but it's fixed the problem.
     
  8. George-Dolbier

    George-Dolbier

    Joined:
    Sep 1, 2013
    Posts:
    9
    Same problem, different platform, on Mac OSX, had skipped 2018 unity versions, because reasons, also had not updated visual studio community. Updated to Unity 2019.1 (Prefab editor and TMPRO 2.0 FTW) and visual studio started marking _everything_ red. Downloaded and updated to Visual Studio Community 8.0.6 (and all it's dependancies_ and POOF no more complaints
     
  9. unity_JIObz70PulkSVw

    unity_JIObz70PulkSVw

    Joined:
    Feb 11, 2021
    Posts:
    1
    You just need to uninstall VS and back again selectingthe unity hub and thats it. It indeed happened after an Unity Update