Unity not finding scripts in folder - c#

I just opened a Unity project that was functioning yesterday, only to get an error:
error CS0246: The type or namespace name 'X' could not be found (are you missing a using directive or an assembly reference?)
The error is called when another script Y tries to extend a class defined in X:
public class Y: X
{...}
Both X.cs and Y.cs are in the same folder.
The project ran/compiled with no problems yesterday. Since then I have rebooted the machine, but no other changes were made. I have tried deleting the Library folder with no success.
Unity v# 2020.3.33f1, I am using visual studio code as an editor.
Any thoughts would be much appreciated. Thanks!

Suggestions:
First check if the class name and the file name is same (which is obvious to check ofcourse)
secondly reimport the vs code pacakge from package manager and restart unity and vs code hope fully it will fix the problem if not then last step would be to check if by accident or willingly you have put the 'X' class inside a namespace and not mentioned that namespace where you trying to inherit in 'Y' class, but most probably I think second option should fix it.

Related

Is there a way to track which assembly definition a script belongs to?

I upgraded my project to Unity 2021 and have tons of the same error:
error CS0246: The type or namespace name could not be found (are you missing a using directive or an assembly reference?)
This is for both packages and my own scripts. I added an assembly definition in my main scripts folder and tried to add a reference but I couldn't find the proper one to fix any issue.
For example, I'm using the RootMotion FinalIK and PuppetMaster assets. All scripts referencing these have using RootMotion.FinalIK and using RootMotion.Dynamics However, the script doesn't recognize RootMotion.Dynamics and every variable type using RootMotion.FinalIK cannot be found.
Any ideas?
The fix was to just restart Unity and VSCode.

Can you connect to a BotFramework bot in Unity using Directline?

I've created a reference in script to Universal.Microsoft.Bot.Connector.DirectLine in Visual Studio 2019 and everything looks fine but after I save and return to Unity, I get the following error:
error CS0246: The type or namespace name 'Universal' could not be found (are you missing a using directive or an assembly reference?)
I tried adding a reference to 'Universal' by Creating an Assembly Definition Reference asset, but did not see Universal on the list of references to add.
I'm wondering if what I'm trying to do is even possible in Unity.
You can find the package on Nuget, and grab the DLLs (and any DLLs it depends on) and put them into Assets/Plugins
https://www.nuget.org/packages/Microsoft.Bot.Connector/
if it has different folders/versions pick the Standard version

Getting namespace does not exist error for all the references added in my project

Whenever I take the latest code from TFS and tries to build existing solution, It fails all the project building and says that : The type or namespace name 'XYZ' does not exist in the sampace 'a.b.c' (are you missing an assembly reference?)
This is happening with all the references and only in my system. On the other systems all these code works fine.
Can it be a Visual Studio issue or some setting which might have got changed?

Unity 3D is not loading new references from MonoDevelop

I'm trying to create a new variable with:
public Text customText;
To use the type Text, I need to include:
using UnityEngine;
using UnityEngine.UI;
But this reference doesn't exist in my list of references on MonoDevelop.
I download it manually and added the reference manually; now I can use the Text type and import the UnityEngine.UI.
Well, here is the issue. When I compile my solution, on MonoDevelop I get this error:
Error: The compiler appears to have crashed. Check the build output pad for details. (Assembly-CSharp).
But on Unity3D I get the error:
Assets/UI/Scripts/HudController.cs(2,19): error CS0234: The type or namespace name `UI' does not exist in the namespace `UnityEngine'. Are you missing an assembly reference?
The dll UnityEngine is by default in the list of references, but not the UnityEngine.UI.
What I'm doing wrong?
I've faced this problem. Actually i've seen few solutions, but they helped me for only few launches of Unity.
Here is the links:
1) http://forum.unity3d.com/threads/unityengine-ui-dll-is-in-timestamps-but-is-not-known-in-assetdatabase.274492/#post-2015083 (post by j.robichaud)
2) http://answers.unity3d.com/questions/847994/unityeditorui-reference-missing.html
I hope any of it will help you.
In my case only reinstall was the cure. :)

Why am I getting the following error when compiling this assembly?

I'm attempting to use the following command line command to compile an assembly of the code from my project:
C:/"Program Files"/Unity/Editor/Data/Mono/bin/gmcs
-target:library -out:C:/Users/Austin/Desktop/PixelExpanse.dll
-recurse:C:/Users/Austin/Desktop/Projects/Repos/trunk/PixelExpanse/SpaceColonyRefactor/Assets/Source/*.cs
-d:RUNTIME -r:C:/"Program Files"/Unity/Editor/Data/Managed/UnityEngine.dll
As you can see, I am, I believe, correctly referencing the UnityEngine.dll.
The code that would be compiled contains references to UnityEngine.UI and UnityEngine.EventSystems. But when I run the above command, I get the following compile error:
error CS0234: The type or namespace name 'EventSystems' does not exist in the namespace 'UnityEngine'. Are you missing an assembly reference?
From what I have been able to find through googling, it SEEMS like an error people were getting when using a pre-4.6 assembly, because thats when EventSystems and UI were both introduced. But I don't know how I could be missing that in the dll I'm referencing as Unity 5 is the only version that has ever touched this computer.
As a side note, I have posted this question to Unity Answers and have yet to receive a response. I expect it's because assembly compilation is beyond the scope of what most users there choose to undertake. Hence my asking it here.
The namespace UnityEngine.EventSystems actually appears in UnityEngine.UI.dll and not UnityEngine.dll so it seems you need to reference the former too when compiling manually from the command-line. Unity projects have this by default (see below).
This is verified by opening up the assembly in your reflector tool of choice, here I am using JetBrains dotPeek:
This is how my test project appears with default Unity references. Note that by default a reference to UnityEngine.UI already appears in the Unity-created project:
When I built my Windnows desktop app via Unity, the above dlls appeared in:
<drive>:<projectOutFolder>\<projectName>_Data\Managed
You can try:
right click on "project panel", and after "Reimport All".
It's can be happen due to switch between platforms, e.g. IOS, or Desktop.. thus, folrders are deleted by became unecessary..
Solve for me: Unity 5.2, Win 7, 32bits;
Good luck!
I checked the UnityEngine.dll and the Eventsystems/UI namespace is not included. Despite, there is a dll in Unity5\Editor\Data\UnityExtensions\Unity\GUISystem\UnityEngine.UI.dll which includes these namespaces.
For mac, it's /Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll.

Categories