Skip to content
This repository was archived by the owner on Nov 19, 2020. It is now read-only.
César Souza edited this page Sep 22, 2017 · 25 revisions

Unity (Unity3d)

Unity is a cross-platform game engine developed by Unity Technologies. Since it's 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 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 project is set to use .NET 2.0 instead of .NET 2.0 Subset by navigating to Edit -> Project Settings -> Player and changing 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:

Installing the framework through NuGet

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

  1. Create a new Unity application
  2. Click Edit -> Project Settings -> Player
  3. Change "Api Compatibility Level" from ".NET 2.0 Subset" to ".NET 2.0"
  4. Click Assets -> Open C# Project
  5. 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>
  6. Close Visual Studio
  7. Click Assets -> Open C# Project again to re-open Visual Studio
  8. Right click your solution, then click "Manage NuGet Packages for Solution..."
  9. Click "Browse" in the top left corner
  10. Search for the Accord.NET packages you would like to add (i.e. "Accord.MachineLearning")
  11. Click on your application name on the right to mark its checkbox
  12. Click "Install"
  13. Accept the license terms
  14. 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.

  1. Accord.NET Framework
  2. Getting started
  3. Published books
  4. How to use
  5. Sample applications

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!

Clone this wiki locally