3
\$\begingroup\$

I'm pretty new in Unity and i'm trying to write reusable code to use across multiple "project". So I wrote this class to POST and GET highscore via WebRequest. I compiled the project to a DLL and added the DLL in my assets folder, and then I created a test script added to a GameObject opened it in VS2013 and created a reference to the DLL in the Assets folder, and now im trying to use it and it keep saying that the class name doesnt exist.

enter image description here

\$\endgroup\$
0
2
\$\begingroup\$

A few items you will need to address for a dll to work in monodevelop:

  1. Your class, constructor, and method in the dll must be public
  2. You must use a .net compiler that is compatible with monodevelop (yours is) and the language must also be compatible. F# for example isn't.
  3. Make sure to reference the assembly/dll in your references (i see you did in the screen shot)
  4. Add 'using myclass' as the name from your dll into the header of the monodevelop cs script
  5. Make sure any resources you are using in your dll are available and usable for monodevelop. If you are using another external dll (anything outside of the clr), it becomes a dependency for your dll and must be included as well.

Here is a handy reference from unity on the subject for more reading including how to debug a session between the environments. Otherwise reply with questions if this isn't enough detail to help with your issue.

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

\$\endgroup\$
3
  • \$\begingroup\$ I added the reference to my project, I tried something weird. Could it be bacause I compiled the DLL in .NET 4.5 ? I tried compiling the DLL in .NET 3.0 and I was able to use it in my unity project. \$\endgroup\$ – poudigne Feb 25 '15 at 1:54
  • \$\begingroup\$ It's remarkably difficult to find a compatibility matrix. One I found shows .net 2.0 but most posts indicate its 3.5 with a few 4.0 features thrown in. Its not a Microsoft build but its between those two versions since Unity4.3. I don't have a test handy to try it unfortunately. If you don't mind, leave feedback if you try and it works, I'll update the post for others trying to compile. \$\endgroup\$ – Tim Cederquist Feb 26 '15 at 8:01
  • \$\begingroup\$ Well I have tried compiling it in .Net 3.0 and it Worked. I have not tried other version. I will probably do it this weekend. Thanks a lot \$\endgroup\$ – poudigne Feb 26 '15 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.