Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by mcough2 · May 23, 2013 at 04:42 PM · dllreferenceslibraries

Unity and MathNET

Hey,

I am having a very noob(ish) problem. I would like to use the MathNet.Numerics Library. When I add the following to my code (only that line to code that works otherwise) and add MathNet.Numerics.dll to my references in MonoDeveloper I can build the file. However when I go to run (push the play button) my unity project I get the following error.

using MathNet.Numerics.IntegralTransforms;

error CS0246: The type or namespace name `MathNet' could not be found. Are you missing a using directive or an assembly reference?

I have the MathNet.Numerics.dll file in the same folder as UnityEngine.dll.

I've tried putting the MathNet.Numerics.dll file into my project folder (Assets) but that give the following error.

TypeLoadException: Could not load type 'MathNet.Numerics.Algorithms.LinearAlgebra.ILinearAlgebraProvider' from assembly 'MathNet.Numerics, Version=2.5.0.27, Culture=neutral, PublicKeyToken=null'.

I don't understand what the problem is. Please Help.

Thanks

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

5 Replies

· Add your reply
  • Sort: 
avatar image
13

Answer by AdamBebko · Apr 11, 2016 at 07:33 AM

I got this working.

Steps:

1) Create a folder called Assets/Plugins in your project.

2) go to

https://onedrive.live.com/?id=84F3672F8CDA3E91%21440210&cid=84F3672F8CDA3E91

and download the latest version of MatNet.Numerics.dll in zip format.

3) open the folder called Net35. Unity apparently only runs on this version of .net.

4) copy BOTH MathNet.Numerics.dll AND System.Threading.dll into Assets/Plugins.

Note: Don't touch anything in MonoDevelop. it should reference it automatically.

For me i was installing the newer .net version and I didn't realize it also needed System.Threading.dll. Once I got it in the above format it worked fine.

FYI: I'm on El Capitan OSX11.4 and Unity 5.3.4f1 personal.

Hope that helps! Adam

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image maxdefeber · May 29, 2017 at 07:41 PM 0
Share

Hi @thebebinator, your solution also worked for me! $$anonymous$$any thanks. - $$anonymous$$ax

avatar image SamuelBG13 · Apr 06, 2018 at 01:03 PM 0
Share

I got this working using your instructions @thebebinator . Thanks!

By the way: $$anonymous$$ake sure to use a $$anonymous$$athNet.Numerics version compatible with .NET 3.5. In this OneDrive folder you can find 3.20.2 for instance.

avatar image wgarn · May 31, 2020 at 09:18 PM 0
Share

@AdamBebko's solution still works mostly (Windows 10, Unity 2019.3.9): 1) created Plugins folder in Assets; 2) downloaded "$$anonymous$$athNet.Numerics-4.9.1.zip" from above link; 3) [solution update] copied $$anonymous$$athNet.Numerics.dll from "netstandard2.0" from zip-file into Plugins folder 4) tested with code from @HackAndSlashDev (see below)

By the way the Unity's Asset Store does not have $$anonymous$$ath.Net at the time of writing.

avatar image Catsploration · Apr 06, 2021 at 03:22 PM 0
Share

2021 update: This still seems to be the correct solution with wgarn's modification (use the netstandard2.0 folder instead of the Net35 folder and don't worry about copying over a System.Threading.dll file).

avatar image
3

Answer by HackAndSlashDev · Dec 01, 2015 at 10:40 AM

Well, this answer helped find the answer. I was able to get the Math.NET Numerics 3.9 running on unity on osx El Capitan.

Here are the steps I took:

  • Install NuGet in Monodevelop using this tutorial https://www.youtube.com/watch?v=uHbAgbfgQdU

  • Search for and install Math.NET Numerics using the NuGet plugin. That will also install System.Threading for which you'll have to accept a license agreement.

  • Close monodevelop.

  • NuGet creates a directory called packages under the project folder.
    • I copied "packages/TaskParallelLibrary.1.0.2856.0/lib/Net35" to a folder I named Assets/Libs.

    • Then I also copied the contents of "packages/MathNet.Numerics.3.9.0/lib/net35" to "Assets/Libs/Net35".

    • For correctness sake I placed the readmes and licenses under "Assets/Libs".

    • Finally I deleted the packages directory, and the file Assets/packages.config

That's it. You can test it by dragging the following script onto an object:

 using UnityEngine;
 using System.Collections;
 using Matrix = MathNet.Numerics.LinearAlgebra.Matrix<double>;
 using Vector = MathNet.Numerics.LinearAlgebra.Vector<double>;
 
 
 public class MathTest : MonoBehaviour {
     // *************************************************************************
     void Start() {
         Matrix A = Matrix.Build.DenseOfArray(new double[,] {
             {1,0,0},
             {0,2,0},
             {0,0,3}});
 
         Vector b = Vector.Build.Dense(new double[] {1, 1, 1});
 
         Vector x = A.Solve(b);
         Debug.Log("x = A^-1b: " + x);
     }
 }
 







Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
2

Answer by randomuser · May 23, 2013 at 11:03 PM

You don't add the reference in monodevelop, you add the .dll to your unity project in the editor, which should then add it for use via the "using" statement. Here is the documentation for it:

http://docs.unity3d.com/Documentation/Manual/UsingDLL.html

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by TriangleKing · May 24, 2013 at 10:10 AM

MathNet requires .NET 4, which unity's version of monodevelop doesn't support.

If you manage to get it working, please tell me! I've been trying to use Iridium's stable distribution, but it's giving me bogus numbers. Iridium was discontinued in 2008 so I'm thinking it has lots of bugs. And I really don't want to implement my own probability distributions.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image phaserescu · Sep 26, 2016 at 08:44 AM 1
Share

I've managed to get $$anonymous$$ath.Net working in a Unity3d project and because the steps weren't super clear, I've also created a sample GitHub repo with a working test.

https://github.com/phaser/Unity$$anonymous$$athNet

avatar image
0

Answer by TheD0ctor · Dec 14, 2016 at 06:52 AM

You could use Math.NET for Unity https://www.assetstore.unity3d.com/en/#!/content/77081 https://www.assetstore.unity3d.com/en/#!/content/77082

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

24 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

how to reference an enum from outside a built DLL 1 Answer

Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers

InControl does not work as a managed DLL. 0 Answers

Importing a DLL that contains C#-wrapped C++ Code 0 Answers

System.EntryPointNotFoundException: CreateNLSocket 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges