-
Notifications
You must be signed in to change notification settings - Fork 2k
Unity
Unity (Unity3D) is a cross-platform game engine developed by Unity Technologies. Since its scripting engine is partially based on Mono, it can execute and import .NET code targeting a subset of the .NET 3.5 framework, which includes most of the Accord.NET Framework.
There are two main ways to install and use the Accord.NET Framework from Unity. The first one is to download the framework's libsonly packages from the latest releases page (e.g. Accord.NET-x.x.0-libsonly.rar from https://github.com/accord-net/framework/releases), or install it through NuGet.
While the first approach is guaranteed to work, you might need to take care to also add all framework dependencies manually to your Unity project. If you opt to use NuGet instead, most of the dependencies should be figured out automatically by NuGet itself. However, NuGet support for Unity is experimental at the current time of writing, and your mileage may vary.
Alternatively, you can also download a pre-existing Unity sample application that already comes with the Accord.NET Framework installed and configured and that you will be able to use as a base for your new projects.
To install the framework manually, perform the following steps:
Navigate to the framework's releases page at https://github.com/accord-net/framework/releases
Click to download the "libsonly" .rar release to your computer;
Click to open the file. You will see the binaries are contained inside the "Release" folder.
Navigate to the Release\net35 folder
Extract the libraries that you think you might need in your application. More likely you will need:
- Accord.dll
- Accord.Math.dll
- Accord.Math.Core.dll
- Accord.Statistics.dll
- Accord.MachineLearning.dl
- Accord.Imaging.dll
Open Unity
Create a new or open an existing project
Make sure that your Unity project project is set to use .NET 2.0 instead of .NET 2.0 Subset in the project's settings. For this, navigate to
- Edit -> Project Settings -> Player
and change the property Api Compatibility Level to .NET 2.0 if necessary:
Now, create a folder inside your project to hold the Accord.NET libraries
Copy them manually to your project
Now, open your C# project in Visual Studio, and you will see that the project will have been automatically added to your project references:
To download the framework through NuGet, you can follow the steps below:
Open Unity
Create or open an existing Unity project
Make sure that your Unity project project is set to use .NET 2.0 instead of .NET 2.0 Subset in the project's settings. For this, navigate to
- Edit -> Project Settings -> Player
and change the property Api Compatibility Level to .NET 2.0 if necessary:
Click Assets -> Open C# Project
Create a new file named "nuget.config" in your project's solution with the following contents:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value="Assets\Packages" />
</config>
</configuration>
Close Visual Studio. This is really necessary because the nuget.config file that we have just created will not be parsed/re-interpreted unless we close Visual Studio and re-open it again.
Click Assets -> Open C# Project again to re-open Visual Studio
Right click your solution, then click "Manage NuGet Packages for Solution..."
Click "Browse" in the top left corner
Search for the Accord.NET packages you would like to add (i.e. "Accord.MachineLearning")
Click on your application name on the right to mark its checkbox
Click "Install" and accept the license terms
The framework libraries should have been installed under the Assets folder and can now be used from within Unity
Note: In case one of the libraries you selected has installed SharpZipLib, you might want to delete the net11, SL3 and SL4 versions of this library and leave only the net20 version. Otherwise, Unity will complain saying that multiple versions of a library are being referenced in the project.
A sample application with an example Unity project can be downloaded from here.
Help improve this wiki! Those pages can be edited by anyone that would like to contribute examples and documentation to the framework.
Have you found this software useful? Consider donating only U$10 so it can get even better! This software is completely free and will always stay free. Enjoy!