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
1
Question by Shiver · Oct 06, 2017 at 05:41 PM · c#dllpipelinelibrary

Using 2 DLLs with the same name

I have a DLL (let's call it A.dll) that depends on another DLL (let's call it B.dll) that has two different versions, one for mobile and one for standalone. I want unity to choose the correct B.dll for the build.

My current file structure for my project is something like

 -Assets
   -Libs
     -A.dll //depends on B.dll
     -B.dll //this has it's platform settings set to standalone targets
     -MobileLibs
       -B.dll //this has it's platform settings set to mobile targets

I've set the target platforms in their respective inspectors to be mutually exclusive so there is no name clash when I run the game in the editor but it always uses the standalone B.dll even when I set the player to a Mobile platform. Even worse, if I delete the standalone version of the B.dll, it can't find the other B.dll that is in the MobileLibs folder.

How can I get this to work? Are there any special folders I need to put these into? I've tried renaming the folder Plugins but that didn't seem to make a difference either.

These are C# libraries built using MonoDevelop if that helps.

Comment
Add comment · Show 2
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 Bunny83 · Oct 06, 2017 at 06:20 PM 1
Share

It's not really clear what dll you use for the editor. The platform setting only applies to building the game. You also have to choose one dll for in editor use when you want to test your game inside the editor. If your "mobile" version is a specialized version which only works on a mobile device it's obvious that you can't use that one in the editor. It's common that you would use the standalone DLL inside the editor.

Can you include screenshots of the inspector settings of the two DLLs? Or at least be more clear what exact settings you have checked / unchecked for each DLL.

Have a look at this documentation. You will find some specific folders which might help with your problem.

avatar image Shiver Bunny83 · Oct 09, 2017 at 04:04 AM 0
Share

This put me on the right path. What I didn't understand was that when a dll is chosen for use on the Editor platform, it is used for both when you are in play mode and when you are in editor mode. I thought that setting for Editor was only for in Editor mode and the other platforms would be used depending on which build platform you were using.

2 Replies

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

Answer by Shiver · Oct 09, 2017 at 04:15 AM

For anybody seeing this question in the future, having two DLLs with the same name is fine so long as they target different platforms and are in different directories (the above example, in the question describes such a case).

My problem was that I was trying to use a DLL to wrap UnityEngine.Advertisements content. Although it is possible to do so, it is not possible to setup the DLLs in such a way that the target build platform is reflected correctly during Play Mode in the editor. Only precompiler macros can properly do that but they are not effective in DLLs.

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 MostHated · Apr 26, 2018 at 04:28 AM 0
Share

I am trying to use two different $$anonymous$$ongoDB.Driver and $$anonymous$$ongoDB.Bson drivers. One is for 3.5 the other is 4.x but it doesn't seem to want to let me do that?

avatar image
0

Answer by Glurth · Oct 07, 2017 at 12:33 AM

Unity will assign the precomplier directive UNITY_EDITOR, when compiling for the editor, (including the editor-"player") When compiling for a final project/platform, UNITY_EDITOR is NOT defined.

So...

 #if UNITY_EDITOR
 using a.dll    // used when compiled for the editor (what you get when you hit play)
 #else
 using b.dll   // used when compiled for the runtime project.
 #endif

(Both dll's would live in your regular asset folder.)

EDIT: I should also mention, that each target option has a place where you can specify your OWN preprocessor pragma. You can assign each target a different pragma, and use the pattern shown above, replacing with your own pragmas.

I THINK you have that part already understood though, and it sound like you want to know how to compile the DLL itself. THAT answer is really ugly. Here is how I did it: http://answers.unity3d.com/questions/1347169/how-to-conditional-use-of-unityeditor-in-dll.html (I really hope someone posts a better way!)

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 Bunny83 · Oct 07, 2017 at 02:03 AM 1
Share

Uhm i think that the two DLLs have actually the same namespaces. It's just two different implementations. At least that's what i understood from the question.

ps: There's not really any other way in your case as pre-processor tags are only read before the actual compilation. Since your DLL is already in compiled form the tags doesn't exist anymore. So you would have to create two seperate versions. Even all of the Unity extensions have seperate Editor and runtime versions. Just look into "Unity/Editor//Data/UnityExtensions/Unity/" The new GUI system as well as the networking library have a seperate editor and standalone version.

The "UnityHoloLens" extension also seems to have a seperate Editor, Runtime and RuntimeEditor version.

avatar image Glurth Bunny83 · Oct 07, 2017 at 05:00 AM 0
Share

"Even all of the Unity extensions have seperate Editor and runtime versions" How does it know which one to use for a given compilation? I would suspect some difference in the "command line" issued to the compiler. How ever it is done can we somehow "tap" into that?

avatar image Bunny83 Glurth · Oct 07, 2017 at 09:30 AM 1
Share

Well, extensions of course work a bit different as they are handled by the editor in a different way. However in general you should be able to use the plugin inspector to specify for which platforms an assembly should be used. Though as the question was written it seems that what he's doing but we don't know his actually settings on the two B assemblies. That's why i posted my comment on the question.

There are also special folders which Unity recognises for different platforms. All can be read on this page:

To make transition easier from earlier Unity versions, Unity will try to set default plugins settings, depending on the folder where the plugin is located.

So the plugin inspector settings should actually be enough. Though many people do not recognise the editor as seperate platform.

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

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

Including a DLL in unity? 1 Answer

Multiple Cars not working 1 Answer

How to build a game with Leap Motion ? 1 Answer

Distribute terrain in zones 3 Answers

Can Unity track the changes I made to my DLL? 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