Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by Charliea835 · Nov 21, 2018 at 07:08 PM · unity 5visual studiodll

developing a C# library with visual studio to use with Unity

Hi, I am trying to develop a C# library through visual studio so I can use it inside unity, I have found a few sites that give instructions as to how to create a dll and access it through Unity but I find most instructions online are too vague. can anyone post some instructions on how to do so? I'm trying to do this through visual studio 2017

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by michi_b · Nov 21, 2018 at 07:49 PM

First, start the visual studio installer, click "Modify" for Visual Studio 2017 and in the opening window, make sure that ".NET desktop development" in the top right corner is checked. Check it and click "Modify" if it wasn't installed (I think it's checked per default), otherwise just exit.

Next, open Visual Studio and go to File->new->Project. Find the subcategory "Installed/Visual C#/Windows Desktop" on the left side, then choose "Class Library (.NET Framework)". Also make sure that you choose "Framework: .NET Framework 3.5" in the bottom left corner of the window. Name your project anything you want, give it the location you want, hit "OK".

Visual Studio now has already created an empty class "Class1" in the project's root namespace for you. Now you can already hit F7 or click "Build->Build Solution" to create the dll file. Open the file explorer and go to "(the solution folder you chose)/(the class library project name you chose)/bin/Debug/". There should be the dll file named like your project. You can already drop this into an Unity Assets folder. Then you should be able to access (the pretty useless) (your root namespace name).Class1 from the scripts in your Unity project.

These are only the basics, you probably also want to reference the UnityEngine.dll from your class library, to be able to use the Monobehaviour class in that library etc. You can also create debug symbols for Unity to be able to debug into the class library when debugging your Unity scripts. But this is all sufficiently well explained in the Manual I think.

Comment
Add comment · Show 3 · 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 Charliea835 · Nov 21, 2018 at 08:06 PM 0
Share

thank you for the well-detailed reply, I shall try this immediately, I need to allow unity to access functions compiled in this dll, is there a particular way to call a function from the dll?

avatar image michi_b Charliea835 · Nov 21, 2018 at 08:10 PM 0
Share

If the containing class and the method you want to call are public, you should be able to call it from your scripts in the Unity project just like any other method that you call from other C# scripts in your Unity project.

avatar image michi_b Charliea835 · Nov 21, 2018 at 08:45 PM 0
Share

just make sure that your classes and methods in your dll are explicitly public, not internal

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

185 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 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 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 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 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 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 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 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

Once and for all - how do i make Visual Studio open one instance 1 Answer

Implement non-mono visual studio c# project 1 Answer

[Solved]Autocomplete in Visual Studio Won't Work, Please Help! 5 Answers

Game lagging so much on android 0 Answers

Access a file after build in unity 0 Answers


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