I run into this problem every few months and it annoys the crap out of me. I do not understand what causes this or how I seem to keep fixing it. But every once and awhile I will update Unity, switch git branches or something and then all of a sudden Unity can not find packages imported from GitHub.
I can see that the libraries are in my unity packages folder but Unity can not see them. Here you can see MyBox and xNode are in my Unity Packages folder.
The funny thing about the error, highlighted below, is that the line of code it is complaining about possibly not having a using directive for xNodeEditor... is a using directive for xNodeEditor...
Here is the error I am getting for that line. "Assets\Editor\xNode\DialogueNodeEditor.cs(2,7): error CS0246: The type or namespace name 'XNodeEditor' could not be found (are you missing a using directive or an assembly reference?)"
I don't think this is a namespace issue as I don't use namespaces. I am sorry I can't provide more information I do not know what I did recently to my project before this started again.
Not sure if this is relevant but here is my GameAssembly where you can see MyBox and xNode are present.
As I stated in the comments, closing Unity before switching branches seems to help minimise how much Unity freaks out.
After, if VS is no longer recognising libraries in your code / Unity's built in scripts it may have to do with not opening the SLN file.
Here is a part of a tutorial I wrote as this problem occurred on the school computers.
If VS says "Miscellaneous Files" just under the scripts name tabs it has not properly opened the Unity files. Fix this by closing VS and opening by clicking in Unity "Assets" then "Open C# Project" it may prompt you to specify a SLN file.
Even if VS does not say the files are misc it seems to help to open via assets rather than double clicking a script.
Related
I pretty much looked everywhere... but couldn't find anything that could debug my problem.
The only thing I do in a script is "using UniRx" to have the following error : The type or namespace name 'UniRx' could not be found.
What i tried:
On Unity, downloading from Package Manager with "Add Package with git URL"
On Unity, downloading from Package Manager with the normal way: Download -> import (into folder Plugins)
On each part, i also tried:
"Reimport All"
Closing and opening back Unity Hub then Unity
I found nothing much on google except for having this problem only on Visual Studio (which is not my actually problem since Unity itself doesn't accept UniRx)
But those who have that problem, i read that you need to "Assets" -> "Open C# Project"
Can anyone help me with my problem on Unity ? Searched for hours but still stuck :(
Unity Version: 2021.3.3f1
Well seems like my problem was like fafase said... I totally forgot about assemblies since i don't use Unity much and since it's been a long time i didn't continue my project.
I'm trying to use ClearScript in Unity, but fail because Unity does not see the DLL.
To be sure, I cloned the project and had the DLLs built. I did this using the instructions from ClearScript.
The goal is to use the DLL on HoloLens, which in turn means I have UWP as the platform and ARM64 as the architecture.
But I also want to have valid references during the implementation in Unity and not have constantly grayed out code because of the scripting symbols (such as UNITY_WSA).
So what did I do?
Screenshot - I took the dlls out of the output-net4.5-folder and set the api compatibility level in unity to .NET 4.x. The red ones are the dlls that I need and the blue ones only if I realy need to use V8, like already mentioned by the instruction from ClearScript.
All the dlls, except "..win-x64|86.dll", are managed dlls and should work out of the box in unity. So this are the import settings for the managed dlls and the settings for the unmanaged|native dlls.
So what did I miss or what did I do wrong? I used in the past for example another javascript interpreter, called Jint, where I also just took the managed dll out of the .net-4.5-build folder, imported it under Assets/Plugins/Jint and used it in my code just by adding the using in my classes.
I'm not sure if I should actually be happy or sad. Unity does what it feels like doing. The whole time (2 days) it didn't want to load the DLL for me. Just now I opened Unity for the 30th time and suddenly Unity recognized the DLL and listed it under references in the vs-unity-project.
So I doubted whether Unity, after making changes in Unity, actually reassembles the VS project.What did I do to confirm the guess and what do you need to do to solve the problem? I added a new DLL, this of course was not seen by unity and not referenced in the vs-unity-project. Then I deleted the solution file and the C# project file from the Unity project and restarted Unity. And when I reopened the VS Unity project (by opening a c# script), all the DLLs including the new DLL were suddenly referenced and the usings worked!
I was following this tutorial https://www.youtube.com/watch?v=8VVgIjWBXks
about making a multiplayer game in unity using Mirror https://assetstore.unity.com/packages/tools/network/mirror-129321.
So obviously I went to the asset store and imported it... (I'm using unity 2020.1)
But now it's throwing a ton of errors and not letting me use "using Mirror;"
VSCode says: The type or namespace name 'Mirror' could not be found (are you missing a using directive or an assembly reference?) [Assembly-CSharp]
Interestingly enough I can run the game without any issues even with all the errors but when I try in my code to "using Mirror;" it doesn't work
I tried reimporting and restarting the project, regenerating .csproj files, and even trying on different unity versions but nothing worked. I'm assuming that the Mirror package itself is totally fine but I'm doing something stupid....
Any idea what I could do?
This seems to be the problem:
Most likely the version of VS Code you have installed, reverting VS Code C# Extension from 1.23 to 1.22.
The short term fix involves literally deleting Mirror from Unity and re-importing it from the Package Manager. Also deleting *.vscode and *.SLN files.
A proper discussion about this issue is found at Omnisharp-vscode GitHub page.
I had to ensure player settings had scripting define symbols:
MIRROR
MIRROR_17_0_OR_NEWER
I have a folder in my Unity's Assets directory that contains several scripts with errors and missing directives, etc...
So, I looked for a way of getting Unity to disregard all those scripts until I have found the directives and solution...
I found out that in MonoDevelop, I could click on the little Settings icon that appears to the right of every script (on the Solution viewpad) and change their setting from Compile to None, but this still does not exclude them from being compiled, so I still get error messages that prevent me from running my Unity app.
Is there another way of doing this, without having to cut that directory out of my Unity project through windows explorer?
As far as I know - no, you can not do that: http://forum.unity3d.com/threads/excluding-unreferenced-scripts-from-builds.13406/
Because it's a development issue, you can just comment out all the code in those scripts. Ctrl/Cmd + A, then Ctrl/Cmd + /.
I'm doing some web development and I did a commit & sync via GitHub's Mac GUI, then I installed some Mac updates that required a restart (I don't know what the updates were). When I opened my project in PHPStorm again, I found this error when I tried compiling my TypeScript:
/usr/local/bin/tsc
env: node: No such file or directory
I know the compilation was working before. My web application had no issues. This question deals specifically with me being able to do this yesterday, with no changes to the FileWatcher configuration.
I have my TypeScript Compiler in usr/local/bin/tsc (which I have checked as a valid path to a typescript compiler alias). When I click on the alias, It opens a terminal window and runs typescript, so I know it's there. PHPStorm also complains if I try to change the file path, saying I must pick a valid executable.
I modified my Environment Variables on the advice of Dan Clark's site but that hasn't changed anything. I don't have the reputation to upload a photo of my File Watchers Dialog.
Does anyone know why I am getting this error, and how it can be fixed? I mention GitHub because that's the last thing I did before things stopped working: a commit & sync, then a restart to install some Mac updates.
Both which node and which tsc point in the right direction. Just tsc also works.
My solution was to use the directory of the actual TypeScript compiler at /usr/local/lib/node_modules/typescript/bin/tsc
instead of
/usr/local/bin/tsc, which is the alias.
That lets me compile using the FileWatcher.
As for why this happened, it's still a mystery to me.