Пример #1
0
        static UnityLogEntries()
        {
            // TODO Unity <5.6 backward compatibility?
            Type logEntriesType = typeof(InternalEditorUtility).Assembly.GetType("UnityEditorInternal.LogEntries") ?? UnityAssemblyVerifier.TryGetType(typeof(Editor).Assembly, "UnityEditor.LogEntries");

            if (logEntriesType != null)
            {
                PropertyInfo consoleFlagsProperty = UnityAssemblyVerifier.TryGetProperty(logEntriesType, "consoleFlags", BindingFlags.Static | BindingFlags.Public);

                if (consoleFlagsProperty != null)
                {
                    UnityLogEntries.SetConsoleFlags = (Action <int>)Delegate.CreateDelegate(typeof(Action <int>), null, consoleFlagsProperty.GetSetMethod());
                    UnityLogEntries.GetConsoleFlags = (Func <int>)Delegate.CreateDelegate(typeof(Func <int>), null, consoleFlagsProperty.GetGetMethod());
                }

                UnityLogEntries.StartGettingEntries = (Func <int>)Delegate.CreateDelegate(typeof(Func <int>), null, UnityAssemblyVerifier.TryGetMethod(logEntriesType, "StartGettingEntries", BindingFlags.Static | BindingFlags.Public));
                UnityLogEntries.SetConsoleFlag      = (Action <int, bool>)Delegate.CreateDelegate(typeof(Action <int, bool>), null, UnityAssemblyVerifier.TryGetMethod(logEntriesType, "SetConsoleFlag", BindingFlags.Static | BindingFlags.Public));
                UnityLogEntries.EndGettingEntries   = (Action)Delegate.CreateDelegate(typeof(Action), null, UnityAssemblyVerifier.TryGetMethod(logEntriesType, "EndGettingEntries", BindingFlags.Static | BindingFlags.Public));
                UnityLogEntries.GetCount            = (Func <int>)Delegate.CreateDelegate(typeof(Func <int>), null, UnityAssemblyVerifier.TryGetMethod(logEntriesType, "GetCount", BindingFlags.Static | BindingFlags.Public));

                Type       logEntryType     = typeof(InternalEditorUtility).Assembly.GetType("UnityEditorInternal.LogEntry") ?? UnityAssemblyVerifier.TryGetType(typeof(Editor).Assembly, "UnityEditor.LogEntry");
                Type       delegateType     = Type.GetType("System.Func`3[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[" + logEntryType.AssemblyQualifiedName + "],[System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
                MethodInfo GetEntryInternal = UnityAssemblyVerifier.TryGetMethod(logEntriesType, "GetEntryInternal", BindingFlags.Static | BindingFlags.Public);
                UnityLogEntries.GetEntryInternalMethod = Delegate.CreateDelegate(delegateType, null, GetEntryInternal);

                UnityLogEntries.GetEntryCount = (Func <int, int>)Delegate.CreateDelegate(typeof(Func <int, int>), null, UnityAssemblyVerifier.TryGetMethod(logEntriesType, "GetEntryCount", BindingFlags.Static | BindingFlags.Public));
                UnityLogEntries.Clear         = (Action)Delegate.CreateDelegate(typeof(Action), null, UnityAssemblyVerifier.TryGetMethod(logEntriesType, "Clear", BindingFlags.Static | BindingFlags.Public));
            }
        }
Пример #2
0
        static DragObjectDrawer()
        {
            if (DragObjectDrawer.ScriptAttributeUtility != null)
            {
                DragObjectDrawer.s_DrawerTypeForType = UnityAssemblyVerifier.TryGetField(DragObjectDrawer.ScriptAttributeUtility, "s_DrawerTypeForType", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
                DragObjectDrawer.BuildDrawerTypeForTypeDictionary = UnityAssemblyVerifier.TryGetMethod(DragObjectDrawer.ScriptAttributeUtility, "BuildDrawerTypeForTypeDictionary", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
                DragObjectDrawer.DrawerKeySet = UnityAssemblyVerifier.TryGetNestedType(DragObjectDrawer.ScriptAttributeUtility, "DrawerKeySet", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);

                if (DragObjectDrawer.DrawerKeySet != null)
                {
                    DragObjectDrawer.drawer = UnityAssemblyVerifier.TryGetField(DragObjectDrawer.DrawerKeySet, "drawer", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
                    DragObjectDrawer.type   = UnityAssemblyVerifier.TryGetField(DragObjectDrawer.DrawerKeySet, "type", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
                }

                if (DragObjectDrawer.s_DrawerTypeForType == null ||
                    DragObjectDrawer.BuildDrawerTypeForTypeDictionary == null ||
                    DragObjectDrawer.DrawerKeySet == null ||
                    DragObjectDrawer.drawer == null ||
                    DragObjectDrawer.type == null)
                {
                    DragObjectDrawer.ScriptAttributeUtility = null;
                }
            }

            HQ.SettingsChanged += () =>
            {
                if (HQ.Settings == null)
                {
                    return;
                }

                if (HQ.Settings.Get <DraggableObjectSettings>().active == true)
                {
                    DragObjectDrawer.AddType();
                }
                else
                {
                    DragObjectDrawer.RemoveType();
                }
            };
        }
Пример #3
0
        static ConsoleUtility()
        {
            if (ConsoleUtility.ContainerWindow != null)
            {
                ConsoleUtility.windows = UnityAssemblyVerifier.TryGetProperty(ConsoleUtility.ContainerWindow, "windows", BindingFlags.Static | BindingFlags.Public);
                // After 5.5, they renamed mainView by rootView.
                ConsoleUtility.mainView = ConsoleUtility.ContainerWindow.GetProperty("mainView", BindingFlags.Instance | BindingFlags.Public) ?? UnityAssemblyVerifier.TryGetProperty(ConsoleUtility.ContainerWindow, "rootView", BindingFlags.Instance | BindingFlags.Public);
            }

            if (ConsoleUtility.View != null)
            {
                ConsoleUtility.allChildren = UnityAssemblyVerifier.TryGetProperty(ConsoleUtility.View, "allChildren", BindingFlags.Instance | BindingFlags.Public);
            }

            if (ConsoleUtility.DockArea != null)
            {
                ConsoleUtility.m_Panes = UnityAssemblyVerifier.TryGetField(ConsoleUtility.DockArea, "m_Panes", BindingFlags.Instance | BindingFlags.NonPublic);
                ConsoleUtility.AddTab  = ConsoleUtility.DockArea.GetMethod("AddTab", new Type[] { typeof(EditorWindow) }) ?? UnityAssemblyVerifier.TryGetMethod(ConsoleUtility.DockArea, "AddTab", new Type[] { typeof(EditorWindow), typeof(Boolean) });
            }
        }