Search Unity

Please help annoying MonoBehaviour missing problem

Discussion in 'Scripting' started by MaZy, Nov 3, 2017.

Thread Status:
Not open for further replies.
  1. MaZy

    MaZy

    Joined:
    Jun 29, 2012
    Posts:
    105
    I have in last time the expierence every new C# file which I create in the UnityEditor do not get correctly loaded.

    MonoBehaviour is always white like it would not exists.. also all namespaces and classes are not loaded. If I restart Visual Studio it is same effect. The only help is to restart unity editor itself. But this is ANNOYING, because it needs to load up again and all the registered UNDO list is removed.

    What can I do? I already deleted vs studio project files, library folder, obj folder. I don't know anymore. I would understand if this happens to every 5 files.. no it happens to all new files.
     
    Last edited: Nov 3, 2017
  2. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    315
    You would understand if this happened only to some files but not to all files? What is the discriminating characteristic of the one-in-five files to which you would understand this happening? Maybe we can start there...
     
  3. MaZy

    MaZy

    Joined:
    Jun 29, 2012
    Posts:
    105
    From my expierence (before above problem) and others it happens not for every new C# file but around 5th file. With restarting the VS 2017 it worked again. It does not work for me now.

    I noticed also after restarting Unity I get "File not Found" error if a c# file saved in the editor folder. I needed to delete VS 2017 project files. Then it worked again.
     
  4. TaleOf4Gamers

    TaleOf4Gamers

    Joined:
    Nov 15, 2013
    Posts:
    825
    I dont have much to contribute but say that this bug is super common and I am flabbergasted that there has been no effort made to fix it. (That I know of).
    It completely breaks my flow when this occurs because like you have experienced no matter what I do, it refuses to acknowledge the existence of the Unity API.
     
  5. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    315
    I've never heard of it but I don't let Unity compile and of my scripts. Just write everything in visual studio, set the compiler output path to Assets\bin, and carry on living your life.
     
  6. TaleOf4Gamers

    TaleOf4Gamers

    Joined:
    Nov 15, 2013
    Posts:
    825
    The issue is that none of the intellisense works. It just makes writing code more tedious.
    Compilation of the code is fine.
     
  7. MaZy

    MaZy

    Joined:
    Jun 29, 2012
    Posts:
    105
    To demonstrate it I created complete new project and recorded it.

    https://streamable.com/15aqm

    You can see there I create two files. The first one works normal as excepted. The second one does not work anymore.
    Even if I restart VS 2017.

    So if I restart the editor itself. Most time it works but its really annoying because I need to load up everything again. For example for android apps I need to reenter password. I also noticed if I rename a file in this case renamed "Test.cs".. so suddently it is working. In another project this didn't work

    Edit: Maybe I found a little solution. If I create new file VS 2017 shows me that the project file got modified from outside. So it asks me to ignore / ignore all or reload / reload project I noticed if I choose reload project it bugs.. but if I click on reload ... so every file which was not correctly loaded gets loaded now.
    I tried it multiple times and it works
     
    Last edited: Nov 5, 2017
  8. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    315
    I don't know what to tell you. That seems like a lot of work when compared to just not managing your .cs files in Unity, which is really easy and works all the time.
     
    Kurt-Dekker likes this.
  9. LeovonUser

    LeovonUser

    Joined:
    Jun 27, 2021
    Posts:
    4
    Having the same issue. I'm writing right now in hope to revive this thread since no one found a great solution, with the exception of post #7. But this doesn't apply to my case, where I just edit the scripts loosely without any project file from the VS side of things.

    The problem is that in the newer versions, this issue is preventing me to even attach the scripts to the game objects, which means that it is preventing me for being able to implement the scripts, which is nessecary for testing and... Well, the functions of the game.

    Never worked in my case, had to type everything by hand, because VS doesn't know the statements of Unity. (probhably because I only edit it loosely without integretion except the opening with VS but that is not the topic here)
     
  10. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,689
    This may help you with intellisense and possibly other Visual Studio integration problems:

    Sometimes the fix is as simple as doing Assets -> Open C# Project from Unity. Other times it requires more.

    https://forum.unity.com/threads/intellisense-not-working-with-visual-studio-fix.836599/

    Also, try update the VSCode package inside of Unity: Window -> Package Manager -> Search for Visual Studio Code Editor -> Press the Update button

    Also, this: https://forum.unity.com/threads/no-suggestions-in-vscode.955197/#post-6227874
     
    LeovonUser likes this.
Thread Status:
Not open for further replies.