• 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 TMPxyz · Apr 08, 2014 at 02:39 AM · editormonoconsolereference assemblies

I'm creating an editor script console, but failed at Loading UnityEditor assembly

Hi there,

I'm writing a small editor script console with Mono's Evaluator when Unity is in edit mode, so I could do some adhoc or repetitive work faster than the monodevelop->newFile->code->compile->run cycle.

Well, it works well mostly, but there's a big problem.

I cannot reference the "UnityEditor" assembly. it will throw exception when I try to reference it

 NullReferenceException: Object reference not set to an instance of an object
 Mono.CSharp.TypeManager.IsThisOrFriendAssembly (System.Reflection.Assembly assembly)
 Mono.CSharp.Namespace.RegisterExternalExtensionMethodClass (System.Type type)
 Mono.CSharp.RootNamespace.RegisterExtensionMethodClass (System.Type t)
 Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType)
 Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType)
 Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx)
 Mono.CSharp.Evaluator.ReferenceAssembly (System.Reflection.Assembly a)
 EditorConsole._Start () (at Assets/Editor/EditorConsole.cs:172)
 EditorConsole.OpenConsole () (at Assets/Editor/EditorConsole.cs:36)

This drawback forbids a lot of useful classes, like AssetDatabase,Selection,etc.

I would be grateful if you know how to solve this problem. Thanks in advance.

alt text

editorconsole1.jpg (45.6 kB)
Comment
Add comment · Show 3
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 frarees · Apr 08, 2014 at 08:45 AM 0
Share

Can you post the related code here? $$anonymous$$aybe it helps to spot the problem.

avatar image Statement · Apr 08, 2014 at 11:37 AM 0
Share

Dunno what you are doing so it's hard to give advice. Are you sure it's failing loading UnityEditor.dll? Could it be a dependency of UnityEditor.dll? If stuck, you could also look at Unitys mono source code to try and figure out the cause of it.

avatar image TMPxyz · Apr 13, 2014 at 02:33 AM 0
Share
 $$anonymous$$ono.CSharp.Evaluator.Init(new string[] { /*"-warnaserror-"*/ });
 foreach (System.Reflection.Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
 {
     //Dbg.Log("refer: {0}", assembly.FullName);
     if (assembly.FullName.Contains("Cecil")
         || assembly.FullName.Contains("UnityEditor")
         )
         continue;
 
     $$anonymous$$ono.CSharp.Evaluator.ReferenceAssembly(assembly);
 }

I didn't find the reason behind this via watching the mono source code, is there some way to debug the mono library, like load some .mdb file?

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

23 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

Related Questions

How do I change the default application used to open logs from the Unity editor? (on Mac) 1 Answer

editor layout - how to put console back to a tab?? 2 Answers

How do I get rid of FMOD errors in the console: "An error occured that wasn't supposed to. Contact support." 2 Answers

Terrain Toolkit Error 2 Answers

Need help with editor (script?) 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