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
3
Question by GeraldOBBI · Dec 11, 2013 at 07:25 PM · editorimportdllmonobehaviourscript loading

Monobehaviours & Editors with Inheritance across DLL boundaries don't load into Unity

Howdy unityAnswers community!

I'm currently spearheading an effort to refactor a bunch of code for our game and have run into a bit of a problem. We're separating a bunch of our code into DLLs, which includes Monobehaviours and Editors (and loose classes).

The issues which I'm running into seem to stem from inheritance across the DLL boundaries specifically for Monobehaviours, and any kind of inheritance for editors which don't directly inherit from UnityEditor.Editor. These scripts work exactly as intended if they are simply placed in the project hierarchy (in their respective folders of course). I've tried placing our DLLs in a plugins folder as well with no change in the script loading.

Below is a small slice which I've taken from our source which highlights the issues. We have a bunch of abstract base classes in our Core DLL which speak to low and mid-level subsystems. Concrete implementations of these classes in the game DLL are passed as their abstract implementations to these systems to be used.

When I look at the imported Monobehaviours under the Core DLL, the TriggerVolume script shows up, which is great however, when I navigate to the Game DLL, the UserCamera script does not show up, and neither does its entry the in the 'Add Component' menu (I have the proper attributes for the classes to show up in this list).

In what I believe to be possibly unrelated issue, it seems that DLLs which contain editors don't load correctly if they inherit from another class which inherits from UnityEditor.Editor. When I attempt to load the editor I get the error: 'Instance of NGUIIconControllerEditor couldn't be created because there is no script with that name. '. Removing the dependency on our intermediate Editor class allows the editor to load normally.

I was really confused that this was happening so after some investigation I was able to see what kind of 'workaround' would resolve the issue. Below is a UML diagram showing the separation of classes across the DLL boundaries as well as the object inheritance.

alt text

In the image below, you can see that I re-ordered the class inheritance so that there are no dependencies on the Core DLL's classes in the Game DLL. This allowed me to load the Monobehaviours and attach them to objects however, it completely breaks the functionality of our game. The broken dependency on BlackBirdEditor however, is something I may be able to live with but not being able to rely on abstract classes in the Core DLL seriously hinders our efforts to pursue this avenue of development.

alt text

I believe the issue may be with the way in which Unity parses the assemblies to figure out which classes are valid Monobehaviours and Editors however, I hope that there is an answer which doesn't involve submitting a bug report because in the 4 or so bug reports I've filed none have ever even been looked at :(

Thanks in advance!

unity dll issue workaround.png (23.1 kB)
unity dll issue.png (19.5 kB)
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 yoyo · Dec 11, 2013 at 07:51 PM 0
Share

Similar question here (but not solution): http://answers.unity3d.com/questions/240985/subclassed-monobehavior-in-external-dlls-not-recog.html

2 Replies

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

Answer by GeraldOBBI · Jul 02, 2014 at 11:55 PM

If anyone out there cares, we had Unity submit a partial fix for this bug which is present in 4.5.x with the limitation that DLLs which have inheritance like this must reside in the same folder.

Comment
Add comment · Show 10 · 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 numberkruncher · Jul 07, 2014 at 11:31 PM 0
Share

This is good to know thanks! though this certainly seems like a strange limitation...

avatar image yoyo · Jul 08, 2014 at 07:27 AM 0
Share

@GeraldOBBI, did you check to see if this works with generics? How about ScriptableObjects?

avatar image xDarkProdigy · Nov 18, 2014 at 09:59 PM 0
Share

This is perfect thanks!!!

However, I do agree with @numberkruncer. Did they mention why that limitation had to be placed?

avatar image GeraldOBBI · Nov 19, 2014 at 01:42 AM 0
Share

No, unfortunately they did not however they did mention that a proper fix would be much more difficult and likely address it further down the line.

avatar image Xtro · May 11, 2015 at 02:06 AM 1
Share

I hate that limitation :( :(

Show more comments
avatar image
0

Answer by Xtro · Jan 28, 2018 at 11:31 PM

I tested this on Unity 2017.3 and it looks like this problem is a history now. Prebuilt dlls can be placed in different folders and they can still contain classes with inherit from classes which are defined in other prebuilt dlls.

Comment
Add comment · 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

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

21 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

Related Questions

Can Editor scripts be in external DLL's or assemblies? 1 Answer

How can we use httpwebrequest in editor 0 Answers

Extending editor without script on GameObject? 1 Answer

How to instantiate a MonoBehaviour from a downloaded DLL at runtime? 0 Answers

[c#] DirectSound 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