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
0
Question by Jian · Oct 08, 2010 at 05:27 PM · reflectionrequirecomponentmanaged

Get types from UnityEngine.dll failed on RequireComponent

Any access to type RequireComponent in UnityEngine.dll will fail. For example: typeof(UnityEngine.UnityEngine.dll)

Reflecting will also fail due to it:

Console.WriteLine(typeof(UnityEngine.Animation).Name);
Assembly a = typeof(UnityEngine.Animation).Assembly;
Type[] tps = a.GetExportedTypes();

The last line will throw an exception saying that type RequireComponent is not in a valid format.

I compiled the code both in SharpDevelop and in XBuild in the Unity Mono folder (C:\Program Files (x86)\Unity\Editor\Data\Mono\bin). Both give the same result.

Is it a bug? If RequireComponent is not supposed to be used then it should be made private so that Assembly.GetExportedTypes() should not try to load it.

Any ways to get around it to get all public types in UnityEngine.Dll?

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
0

Answer by Mike 3 · Oct 08, 2010 at 10:00 PM

RequireComponent is supposed to be used (it's a public attribute which is pretty useful).

The unity 3 assembly has some protection against things in it being called by reflection, so I'm wondering if it's just hitting that

Comment
Add comment · Show 2 · 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 Jian · Oct 09, 2010 at 04:44 AM 0
Share

Not just reflection. Object creation will fail too: UnityEngine.RequireComponent rc = new UnityEngine.RequireComponent(typeof(UnityEngine.Animation));
Use it as an attribute not fail.

avatar image Mike 3 · Oct 09, 2010 at 05:11 AM 0
Share

I'm not entirely sure why you'd ever want to instantiate it - It's a tag for the engine to add the component automatically. If you want to add a component, use AddComponent

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

No one has followed this question yet.

Related Questions

Problem with reflection probe 0 Answers

Get List of Signatures of Messages to Monobehaviour 1 Answer

Fragment Shader pixel gets overwritten 1 Answer

Debug session of managed DLL in VisualStudio? 0 Answers

Require Component for Parent 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