Unity 3D is not loading new references from MonoDevelop - c#

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. :)

Related

Unity not finding scripts in folder

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.

How to solve the error "type or namespace name could not be found" on AssetBundle

I'm doing a project in Visual Studio 2019 integrated with Unity.
When trying to use an asset bundle, i get the error type or namespace name could not be found
The line that gives me the error is
AssetBundle assetBundle = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(typeof(Main), "Name"));
Documentation on asset bundles says that this line should work ok, there doesn't seem to be a reference issue either.
My Unity reference is using UnityEngine;
I'm wondering if I'm missing a step or I'm using the line in a wrong way to use asset bundles.
Turns out I was missing a reference.
using UnityEngine.AssetBundleModule;

Namespace name "Device" does not exist in the namespace

I have a problem using System.Device and can't find a solution
I'm developing a software and want to get the position of the device. By referencing the .NET Framework I want to use the GeoCoordinateWatcher.
In my code I included System.Device.Location and added two packages to the project (GeoCoordinate and System.Device.Location.Portable). While running and debugging the code in monodevelop no error occurs, but when I compile the code with mcs the error mentioned in the title occurs:
Namespace name "Device" does not exist in the namespace
Im using a RasPi for coding and compiling.
Any idea what the problem is?
System.Device is not supported by Mono:
https://github.com/mono/mono/tree/master/mcs/class

Error importing UnityEngine.Experimental.Director

Today I was searching internet for Unity Runtime Level Editor and i found GILES. I imported it and set API Compatibility Level to .NET 2.0, but I canĀ“t solve this error:
Assets/GILES/Settings/pb_Config.cs(75,36): error CS0234: The type or namespace name Director does not exist in the namespace UnityEngine.Experimental. Are you missing an assembly reference?
This error appear in this piece of code:
typeof(UnityEngine.Experimental.Director.DirectorPlayer),
Here is full source of this file on GitHub.
I am using Unity version 2017.1.0f3. Is there any way to fix it? What I am missing?
UPDATE:
I searched in actual Unity documentation and it seems that UnityEngine.Experimental.Director was removed. Is there any alternative or way to use it in new Unity?
I think it is now UnityEngine.Playables.PlayableDirector

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