- Home /
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.
Can you post the related code here? $$anonymous$$aybe it helps to spot the problem.
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.
$$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?
Your answer
Follow this Question
Related Questions
Determine WHAT was just compiled........ 1 Answer
Can I change the destination of selecting console entries 0 Answers
Disable warning messages 5 Answers
Getting console click event. 0 Answers