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 dansav · May 15, 2011 at 12:50 AM · dlllibrarymanaged

How do I use a C# dll library from a script?

I found two math dlls written in c# that I would like to use in Unity3d. one is dotnumerics.dll and another one called MathNet.Iridium.dll

I want to access the routines in these libraries from javascript.

I tried putting the dotnumerics.dll into the assets folder but then what?

I also tried lines like
import DotNumerics
but that doesn't work either.

Does anybody know how to access a c# dll from unity javascript?

thanks,

Dan

Comment
Add comment · Show 1
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 clfischer · May 16, 2012 at 04:18 PM 0
Share

Any luck with this? I'm trying to use $$anonymous$$athNet.Numerics too. I tried to recompile it in Visual Studio for .Net framework 3.5 but then realised that System.Numerics is only available from 4.0. So I'm stuck...

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by DaveA · May 15, 2011 at 01:36 AM

Try creating a Plugins folder under Assets and move the dll files there.

Comment
Add comment · Show 6 · 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 dansav · May 15, 2011 at 02:40 AM 0
Share

That doesn't work.

avatar image DaveA · May 15, 2011 at 04:10 PM 0
Share

Did you read http://unity3d.com/support/documentation/$$anonymous$$anual/Plugins.html

avatar image user-12806 (google) · May 16, 2011 at 05:54 AM 0
Share

Yes. But it's more about creating your own plugin and does not have examples for accessing C# libraries from javascript in the webplayer. Apparently it can be done ...so I hear.

avatar image user-12806 (google) · May 16, 2011 at 05:56 AM 0
Share

I'm not able to make the connection between that document and accessing the library. I'm not familiar with CS just JS for Unity3d.

avatar image DaveA · May 16, 2011 at 06:09 AM 0
Share

Hmm. Not sure your problem then. I was able to simply copy a DLL to my Plugins folder, and access it like it was a regular script (just not see the code). I think I had to drag/drop the dll onto a game object, I forget.

Show more comments
avatar image
0

Answer by cjmarsh · May 15, 2011 at 10:18 AM

You need to reference the specific namespace you are using in the .dll file. For example, (in C#) if you were to use the DotNumerics package for Linear Algebra you'd have to code the following:

using DotNumerics.LinearAlgebra;
using DotNumerics;

Similarly, for MathNet.Iridium:

using MathNet.Numerics;
using MathNet.Numerics.LinearAlgebra;
Comment
Add comment · Show 5 · 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 user-12806 (google) · May 16, 2011 at 05:53 AM 0
Share

How would I access the dll routines from javascript? The examples are all in CS. Someone said that they act just like regular .NET libraries. That's why I was trying to use Import statements...i use import to access the .NET regular expressions library routines... do I first have to create a CS wrapper or something before I use the javascript?

avatar image cjmarsh · May 16, 2011 at 07:46 AM 0
Share

I'm not entirely sure about the JavaScript aspect. The thing is unity actually uses it's own version of JavaScript which is CLR compliant (inter-operable with languages like C++ and C#) so it should be able to import those .dlls (assu$$anonymous$$g you use import rather than using). You could also write a C# wrapper if it doesn't work and basically just import the namespace Wrapper.* or something similar.

avatar image dansav · May 16, 2011 at 05:33 PM 0
Share

It could be the dll itself. Is there a sample dll I could use that everyone knows works? I need to do some sort of testing but am not sure what test to try next.

avatar image dansav · May 17, 2011 at 05:56 AM 0
Share

I tried another dll: dnAnalytics and it gets past the import statement without an error, but then I'm not exactly sure how to call a function. For example there is a function StandardDeviation() but calling StandardDeviation does not work nor does calling Statistics.StandardDeviation() which I believe is the "Namespace?" I'm not sure I understand how to use these namespaces classes, methods in a function call. Right now I get an error that says StandardDeviation is not a member of dnAnalytics or dnAnalytics.Statistics.

avatar image cjmarsh · May 17, 2011 at 01:59 PM 0
Share

http://www.csharp-station.com/Tutorials/Lesson06.aspx has a good tutorial on the differences between namespaces, classes(objects), and methods(functions,programs,etc.). As for the math packages in particular, I can't say I'm too familiar with their implementation as I'm currently translating my math equations into binary numbers.

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

1 Person is following this question.

avatar image

Related Questions

How do I reference components inside a managed .dll? 1 Answer

How do you compile a managed dll with mono/mcs targeting .net 2.0 or 3.5 for Unity? 1 Answer

Cannot compile .exe with specific .dll. (but with other .dlls created the same way) 0 Answers

Is there a garantee that managed Dll plugin will compile on to mobile? 0 Answers

Using dll file from c++ 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