Add class library references to .NET Framework
Reference parts of the .NET class library API that Unity doesn't compile by default.
読み終わるまでの所要時間 2 分最終更新 4日前
By default, Unity references the following assemblies when your project uses the .NET Framework API compatibility level:
mscorlib.dllSystem.dllSystem.Core.dllSystem.Runtime.Serialization.dllSystem.Xml.dllSystem.Xml.Linq.dll
If your Unity project uses a part of the .NET class library API that Unity doesn't compile by default, you can provide the C# compiler with a list of additional assemblies to reference during compilation.
Prerequisites
- Your project's API compatibility level must be set to .NET Framework. If your project targets .NET Standard, all parts of the .NET class library API that can be referenced are already referenced by default. To change the setting, in the Unity Editor go to Edit > . In the Player tab, navigate to the Other Settings tab and in the Configuration section, set Api Compatibility Level to .NET Framework.Project Settings
?
Create a response file
To reference any other class library assemblies, you can create a response (.rsp) file with a list of command-line arguments to pass to the C# compiler as follows:
- Create a file named in the
csc.rspfolder of your Unity project.Assets - Move any assembly files you want to reference into the folder of your project, if they aren't already in this folder.
Assets - Populate the file with command-line arguments for the assemblies you want to reference.
csc.rsp
For example, if your project uses the class, which is defined in the assembly, the C# compiler might produce this initial error message if the assembly isn't present:
HttpClientSystem.Net.Http.dllThe type `HttpClient` is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
To resolve this error, add a file that contains the following command-line argument to the project:
csc.rsp-r:System.Net.Http.dll
Add a new line with the appropriate command-line argument for each assembly you want to reference.