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 spaunn · May 18, 2016 at 02:07 PM · monodevelopdllreferencessolution

how to reference an enum from outside a built DLL

Right, so I'm trying to build a DLL in monodevelop for a package I want to upload to the asset store, but I have an enumeration in the unity project folder who's values I want the user to choose themselves, while the rest of the code is hidden within the DLL thats trying to reference it.

Long story short, how do I reference a c# file outside of the monodevelop solution?

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

Answer by FortisVenaliter · May 18, 2016 at 03:58 PM

You can't. You need to do it the other way around. Put the enum in the DLL with a public modifier in a public namespace. Then, when you import the DLL into Unity, you'll be able to reference the enum.

If you can't do it that way, you'll have to use Reflection.

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 spaunn · May 20, 2016 at 06:39 PM 0
Share

I need the user to be able to choose the values of the enum so I guess I'll have to use reflection. I did a quick google for it but couldn't find anything (not really sure exactly what I'm searching for though)... Could you give me an example of how I can 'reflect' the enum into the compiled dll?

avatar image FortisVenaliter spaunn · May 20, 2016 at 06:41 PM 0
Share

You can't, but you can use the System.Reflection.Assembly class's static functions to get a list of all Assemblies in the project, then search them for the proper enum. It's really messy and not recommended, and will probably only run on Windows.

Really, though, if the user is entering the values, then you should not be using an enum. You should use a String list or array.

avatar image spaunn FortisVenaliter · May 20, 2016 at 06:48 PM 0
Share

hmm.. that's a shame, in my case using an enum is the most ideal type for the user. Cheers for the help though! System.Reflection.Assembly will definitely come in handy at some point!

Show more comments

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Import C# project into my Unity solution 1 Answer

Monodevelop can't find references in Unity 5.3 (C#) 1 Answer

Can I call a js script method inside a C# dll project? 1 Answer

Unity data -> Monodevelop 1 Answer

How to prevent Unity from deleting additional Projects in Solution 2 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