static ConsoleUtility()
        {
            try
            {
                ConsoleWindowType                = UnityEditorDynamic.UnityEditorAssembly.GetType("UnityEditor.ConsoleWindow", true);
                ConsoleWindow_m_ActiveText       = ConsoleWindowType.GetField("m_ActiveText", BindingFlags.Instance | BindingFlags.NonPublic);
                ConsoleWindow_m_ActiveInstanceID = ConsoleWindowType.GetField("m_ActiveInstanceID", BindingFlags.Instance | BindingFlags.NonPublic);

                if (ConsoleWindow_m_ActiveText == null)
                {
                    throw new MissingMemberException(ConsoleWindowType.FullName, "m_ActiveText");
                }

                if (ConsoleWindow_m_ActiveInstanceID == null)
                {
                    throw new MissingMemberException(ConsoleWindowType.FullName, "m_ActiveInstanceID");
                }
            }
            catch (Exception ex)
            {
                throw new UnityEditorInternalException(ex);
            }

            EditorApplication.update += WatchConsoleActivity;
        }
Beispiel #2
0
            protected override Task OnGetTargetMethods(List <MethodBase> targetMethods)
            {
                var method = ConsoleWindowType?.GetMethod("OnGUI", (BindingFlags) ~0);

                Debug.Assert(method != null, "Could not find console OnGUI method. Console?: " + ConsoleWindowType);
                targetMethods.Add(method);
                return(Task.CompletedTask);
            }
Beispiel #3
0
            protected override Task OnGetTargetMethods(List <MethodBase> targetMethods)
            {
                var method = ConsoleWindowType?.GetMethod("StacktraceWithHyperlinks", (BindingFlags) ~0, null, new[] { typeof(string) }, null);

                Debug.Assert(method != null, "Could not find console stacktrace method. Console?: " + ConsoleWindowType);
                targetMethods.Add(method);
                return(Task.CompletedTask);
            }
Beispiel #4
0
 private static MethodInfo GetMethod(
     string key)
 {
     if (!CachedReflection.Has(key))
     {
         CachedReflection.Cache(key, ConsoleWindowType.GetMethod(key, DefaultFlags));
     }
     return(CachedReflection.Get <MethodInfo>(key));
 }
Beispiel #5
0
 private static PropertyInfo GetProperty(
     string key)
 {
     if (!CachedReflection.Has(key))
     {
         CachedReflection.Cache(key, ConsoleWindowType.GetProperty(key, DefaultFlags));
     }
     return(CachedReflection.Get <PropertyInfo>(key));
 }
 public static void PrintMethodInfos()
 {
     if (ConsoleWindowType == null)
     {
         return;
     }
     MethodInfo[] methods = ConsoleWindowType.GetMethods();
     for (int i = 0; i < methods.Length; i++)
     {
         Debug.Log(methods[i].Name);
     }
 }