ML.NET in unity
Asked Answered
P

2

0

There is a new machine learning API from Microsoft, called ML.NET. I have tryed it and it is just great, but, cannot figure out how to use it in unity.
The ML examples are done in Visual Studio projects that target 64 bit processors and are of type .NET Core.

As unity does not support that I am guessing my best bet is to try building a .dll api project and importing it into Unity:

I have tryed building an xxxx.dll api(.net core 2.0 class library) and copyed it into /Assets/plugins folder, but when typing a using xxxx; statement it is as though it was not there.
I have also tryed building a framework api but ML support starts at framework version 4.6.1, and if I build that version, Unity does not recognise the xxxx.dll either.
The same goes for the .net standard api bild.

So I guess my question is: How can I use ML.NET in Unity?

Pondicherry answered 11/7 at 8:38 Comment(4)

By changeing reference framework from 3.5 to 4.x equivalent, I managed to import the api built as framework 4.6.1 with aded reference to ML.NET , But as soon as I add some ML methods to my api the unity editor reports an error , saying my api is not compatible or sth. The same goes for an api built as core 2.0 project. Please help!

Pondicherry

You going UWP or Standalone? If UWP, check the part about placeholder out: https://docs.unity3d.com/Manual/windowsstore-plugins.html

Izard

I have tryed all sorts of combos in player setings and in plugin settings. But have not tried building the app. Not shure what difference this would make... @Izard I was hopieing to build for standalone and android though. But this error persisits even if I exclude UWP from plugin selected platforms. I have reported an issue in github ML.NET repository. Hope someone checks it out soon, aldo I am not entirely shure if it is a ML or a Unity issue.

Pondicherry

@Izard You can dowload a small VS project and an example Unity project in [https://github.com/dotnet/machinelearning/issues/1886][1] . Just unzip and start unity project, the error is shown as soon as the Unity editor starts, no need to press play. [1]: https://github.com/dotnet/machinelearning/issues/1886

Pondicherry
I
0

I had a similar problem when trying to use OracleDataAccess.dll.

I think unity uses different implementations of Core.net classes. These do then not work with DLLs built for the standard .net stuff.
In my case with the oracle stuff I basically had to build a separate application on a webserver that was called by my unity project.

So I guess there is no easy or even acceptable way for your use case. Sorry.

Iridescent answered 11/7 at 8:36 Comment(0)
B
0

There is a full guide how to implement MLNET with Unity. I did already implemented that into my 2 games. Works amazing. MLNET is a game changer

Beautifully answered 11/7 at 8:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.