Unity 2019 error: Feature `out variable declaration’ cannot be used because it is not part of the C# 4.0 language specification

After upgrading Unity editor from 2017 to 2019 you might get some of these errors when you update your old project and hit play:

…/Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Runtime/TMPro_UGUI_Private.cs(1865,73): error CS1644: Feature `out variable declaration’ cannot be used because it is not part of the C# 4.0 language specification

…/Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Runtime/TMPro_Private.cs(1916,130): error CS1644: Feature `out variable declaration’ cannot be used because it is not part of the C# 4.0 language specification

there are other scripts that might give error: TMPro_UGUI_Private.cs, TMPro_Private.cs, TMP_Text.cs, TMP_MaterialManager.cs,… lots of them.

The solution is simple:

Go to : Edit -> Project Settings -> Player -> Other Settings -> Configuration

and change Scripting Runtime Version to .NET 4.x Equivalent, click RESTART and all those errors should disappear.

Scripting Runtime Version

Unity3D – MissingReferenceException: The object of type __ has been destroyed but you are still trying to access it

If you get this error:

"MissingReferenceException: The object of type __ has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object."

then the first thing you should do is to check if you have (additional) inspector window locked. Simply unlock it (you can see the small lock in top right corner of inspector window) and this error should go away.

unity3d inspector lock
I have no idea what is causing it (I am just starting out with Unity) but this solved it. Luckily I found the answer quite fast and did not need to debug and waste a lot of time checking the code when the code was completely fine.