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 Rabadash8820 · Dec 29, 2019 at 07:49 PM · scripting problempluginspackagesreference assemblies

Confusing Transitive Assembly References

TL;DR

How do you write managed plugins in Unity 2019.2+ that reference types defined in Unity Packages, particularly those that used to be defined in UnityEngine.UI.dll, like ScrollRect?

MORE INFO

I have been trying to create two managed plugins (assemblies) to pull out common logic for my Unity projects: UnityUtil.dll, which defines some common types, and UnityUtil.Editor.dll which references and defines custom inspectors for some of the types in UnityUtil. Both assemblies referenced the UnityEngine.dll and UnityEngine.UI.dll assemblies stored in Program Files/, and UnityUtil.Editor also referenced UnityEditor.dll. After upgrading to Unity 2019.2, UnityEngine.UI.dll is no longer present in Program Files/; instead, it is part of the com.unity.ugui Unity Package, and thus ends up in Library/ScriptAssemblies inside the Unity project, so I changed my references to use that path.

Unfortunately, Visual Studio's compiler still wasn't satisfied. One of the classes in UnityUtil is called ScrollRectVelocityClamper, and zeroes out ScrollRect.velocity for very low scroll velocities, as a performance optimization. Unfortunately, I got compiler errors on all lines accessing ScrollRect.velocity, with the following error:

 Error CS0012 The type 'Vector2' is defined in an assembly that is not referenced. You must add a reference to assembly 'UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.

So apparently the new UnityEngine.UI.dll in 2019.2 (which declares ScrollRect.velocity) directly references UnityEngine.CoreModule.dll (which declares Vector2), rather than UnityEngine.dll. So I replaced the UnityEngine.dll reference in UnityUtil with references to the various module assemblies that I'm using (including core module).

But now, my UnityUtil.Editor assembly is unsatisfied. As I did above, I replaced the UnityEngine.dll reference in UnityUtil.Editor with references to the specific Unity modules that I'm using, including the core module. UnityUtil.Editor defines an Editor for a class in UnityUtil derived from ScriptableObject and is showing a similar error to that above:

 Error CS0012 The type 'ScriptableObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.

This error doesn't make sense to me. Why does the compiler think that ScriptableObject is defined in UnityEngine.dll, if both UnityUtil and UnityUtil.Editor are referencing UnityEngine.CoreModule.dll, not UnityEngine.dll? I can't just make UnityUtil.Editor reference UnityEngine.dll also, because then there are duplicate declaration (CS0433) errors. Nor can UnityUtil.Editor reference UnityEngine.dll instead of the module assemblies, because then I get similar CS0012 errors to what I first saw in UnityUtil, about types like Sprite being "defined in an assembly that is not referenced", namely UnityEngine.CoreModule.dll.

Has anyone else run into these complex reference issues when making managed plugins for Unity 2019.2+? I could really use some guidance. Thanks in advance!

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

0 Replies

· Add your reply
  • Sort: 

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

208 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

Related Questions

How to use Unity XR-Plugin Management from script/commandline 0 Answers

Modifications I make to my packages don't save? 2 Answers

I need help with these unity errors regarding post processing and google ads 1 Answer

Integrating Google API: Assembly will not be loaded due to errors 2 Answers

Where Unity Store Package Files in iMac 1 Answer


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