2
votes

I have added Assembly Definition (.asmdef) to my script folder (my custom unity scripts). Now Unity complains that it cannot find OVRInput class which I've used it in one of my scripts (GameManager.cs): enter image description here

This OVRInput class is compiled into Assembly-CSharp.dll managed assembly as seen below:

enter image description here

I expect Unity, by default, to see this dependency and resolve it but somehow it doesn't. So I decided to manually add "Assembly-CSharp.dll" to the dependency section (called "Assembly Definition References") of my assembly but Unity gives error that it cannot find such an assembly.

The following is my custom Assembly Definition File (that puts all of scripts in "Scripts" folder into the assembly):

enter image description here

Target platform: Android (Oculus Gear VR) Unity version 2018.3.13f1.

1
You should create another asmdef to include the Oculus libraryshingo

1 Answers

4
votes

That's kind of the point

Assembly definitions are (effectively) entirely separate projects (part of the same solution, but separate dlls). This is in fact how they are displayed inside Visual Studio's Solution Explorer.

They're meant to be things you reference in to (like TextMeshPro or JsonDotNet) not out of. As such you cannot reference the main Assembly-Csharp "name space."

The advantage is that when a script file changes only its containing assembly is recompiled, instead of the entire project.

In this case, if you want to reference the Oculus files, you either need to create another assembly definition containing those files (and add it as a dependency of your first assembly) or not use an assembly definition at all.