Unity - accord-net/framework GitHub Wiki

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.

Installing the Accord.NET Framework in Unity

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.

Installing the framework manually

To install the framework manually, perform the following steps:

Navigate

Navigate to the framework's releases page at https://github.com/accord-net/framework/releases

Download

Click to download the "libsonly" .rar release to your computer;

Open

Click to open the file. You will see the binaries are contained inside the "Release" folder.

Find

Navigate to the Release\net35 folder

Extract

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

Open Unity

Create

Create a new or open an existing project

Adjust

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:

Create

Now, create a folder inside your project to hold the Accord.NET libraries

Copy

Copy them manually to your project

Voilà

Now, open your C# project in Visual Studio, and you will see that the project will have been automatically added to your project references:

Installing the framework through NuGet

To download the framework through NuGet, you can follow the steps below:

Open

Open Unity

Create

Create or open an existing Unity project

Adjust

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:

Open

Click Assets -> Open C# Project

Configure

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

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.

Re-open

Click Assets -> Open C# Project again to re-open Visual Studio

NuGet

Right click your solution, then click "Manage NuGet Packages for Solution..."

Browse

Click "Browse" in the top left corner

Search

Search for the Accord.NET packages you would like to add (i.e. "Accord.MachineLearning")

Check-it

Click on your application name on the right to mark its checkbox

Install

Click "Install" and accept the license terms

Voilà

The framework libraries should have been installed under the Assets folder and can now be used from within Unity

Note

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.

Download a sample application

A sample application with an example Unity project can be downloaded from here.

⚠️ **GitHub.com Fallback** ⚠️