Exemplo n.º 1
0
        static NGConsoleWindow()
        {
            NGConsoleWindow.nativeConsoleType = UnityAssemblyVerifier.TryGetType(typeof(EditorWindow).Assembly, "UnityEditor.ConsoleWindow");
            if (NGConsoleWindow.nativeConsoleType != null)
            {
                NGConsoleWindow.nativeConsoleWindowField = UnityAssemblyVerifier.TryGetField(NGConsoleWindow.nativeConsoleType, "ms_ConsoleWindow", BindingFlags.NonPublic | BindingFlags.Static);

                if (NGConsoleWindow.nativeConsoleWindowField != null)
                {
                    EditorApplication.update += NGConsoleWindow.AutoReplaceNativeConsole;
                }
            }
        }
Exemplo n.º 2
0
        public UnityLogEntry()
        {
            // TODO Unity <5.6 backward compatibility?
            Type logEntryType = typeof(InternalEditorUtility).Assembly.GetType("UnityEditorInternal.LogEntry") ?? UnityAssemblyVerifier.TryGetType(typeof(Editor).Assembly, "UnityEditor.LogEntry");

            if (logEntryType != null)
            {
                this.instance = Activator.CreateInstance(logEntryType);

                this.conditionField      = UnityAssemblyVerifier.TryGetField(logEntryType, "condition", BindingFlags.Instance | BindingFlags.Public);
                this.errorNumField       = UnityAssemblyVerifier.TryGetField(logEntryType, "errorNum", BindingFlags.Instance | BindingFlags.Public);
                this.fileField           = UnityAssemblyVerifier.TryGetField(logEntryType, "file", BindingFlags.Instance | BindingFlags.Public);
                this.lineField           = UnityAssemblyVerifier.TryGetField(logEntryType, "line", BindingFlags.Instance | BindingFlags.Public);
                this.modeField           = UnityAssemblyVerifier.TryGetField(logEntryType, "mode", BindingFlags.Instance | BindingFlags.Public);
                this.instanceIDField     = UnityAssemblyVerifier.TryGetField(logEntryType, "instanceID", BindingFlags.Instance | BindingFlags.Public);
                this.identifierField     = UnityAssemblyVerifier.TryGetField(logEntryType, "identifier", BindingFlags.Instance | BindingFlags.Public);
                this.isWorldPlayingField = UnityAssemblyVerifier.TryGetField(logEntryType, "isWorldPlaying", BindingFlags.Instance | BindingFlags.Public);
            }
        }
Exemplo n.º 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) });
            }
        }
Exemplo n.º 4
0
        static UnityEventBaseFinder()
        {
            Type type = UnityAssemblyVerifier.TryGetType(typeof(UnityEventBase).Assembly, "UnityEngine.Events.PersistentCallGroup");

            if (type != null)
            {
                UnityEventBaseFinder.PersistentCallGroup = UnityAssemblyVerifier.TryGetField(type, "m_Calls", BindingFlags.NonPublic | BindingFlags.Instance);
            }

            type = UnityAssemblyVerifier.TryGetType(typeof(UnityEventBase).Assembly, "UnityEngine.Events.PersistentCall");
            if (type != null)
            {
                UnityEventBaseFinder.PersistentCall = UnityAssemblyVerifier.TryGetField(type, "m_Target", BindingFlags.NonPublic | BindingFlags.Instance);
            }

            if (UnityEventBaseFinder.PersistentCallGroup == null || UnityEventBaseFinder.PersistentCall == null)
            {
                UnityEventBaseFinder.m_persistantCalls = null;
            }
        }
Exemplo n.º 5
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();
                }
            };
        }
Exemplo n.º 6
0
        static ScenesImporter()
        {
            EditorSceneManager.sceneLoaded     += ScenesImporter.OnSceneLoaded;
            EditorSceneManager.sceneUnloaded   += ScenesImporter.OnSceneUnloaded;
            EditorSceneManager.newSceneCreated += ScenesImporter.OnNewSceneCreated;
            EditorSceneManager.sceneOpened     += ScenesImporter.OnSceneOpened;
            EditorSceneManager.sceneClosed     += ScenesImporter.OnSceneClosed;

            // TODO Unity <5.6 backward compatibility?
            MethodInfo OnActiveSceneChangedInEditModeMethod = typeof(ScenesImporter).GetMethod("OnActiveSceneChangedInEditMode", BindingFlags.Static | BindingFlags.NonPublic);

            try
            {
                EventInfo activeSceneChangedInEditModeEvent = typeof(EditorSceneManager).GetEvent("activeSceneChangedInEditMode");
                activeSceneChangedInEditModeEvent.AddEventHandler(null, Delegate.CreateDelegate(activeSceneChangedInEditModeEvent.EventHandlerType, null, OnActiveSceneChangedInEditModeMethod));
                //EditorSceneManager.activeSceneChangedInEditMode += ScenesImporter.OnActiveSceneChangedInEditMode;
            }
            catch
            {
            }

            // TODO Unity <5.6 backward compatibility?
            MethodInfo OnHierarchyChangedMethod = typeof(ScenesImporter).GetMethod("OnHierarchyChanged", BindingFlags.Static | BindingFlags.NonPublic);

            try
            {
                EventInfo hierarchyChangedEvent = typeof(EditorApplication).GetEvent("hierarchyChanged");
                hierarchyChangedEvent.AddEventHandler(null, Delegate.CreateDelegate(hierarchyChangedEvent.EventHandlerType, null, OnHierarchyChangedMethod));
                //EditorApplication.hierarchyChanged += ScenesImporter.OnHierarchyChanged;
            }
            catch
            {
                FieldInfo hierarchyWindowChangedField = UnityAssemblyVerifier.TryGetField(typeof(EditorApplication), "hierarchyWindowChanged", BindingFlags.Static | BindingFlags.Public);
                if (hierarchyWindowChangedField != null)
                {
                    hierarchyWindowChangedField.SetValue(null, Delegate.Combine((Delegate)hierarchyWindowChangedField.GetValue(null), Delegate.CreateDelegate(hierarchyWindowChangedField.FieldType, null, OnHierarchyChangedMethod)));
                }
                //EditorApplication.hierarchyWindowChanged += ScenesImporter.OnHierarchyChanged;
            }
        }
Exemplo n.º 7
0
        static NGScenesWindow()
        {
            NGEditorApplication.ChangeScene += NGScenesWindow.UpdateLastScenes;

            // Force update allScenes at next restart.
            // TODO Unity <5.6 backward compatibility?
            MethodInfo ResetAllScenesMethod = typeof(NGScenesWindow).GetMethod("ResetAllScenes", BindingFlags.Static | BindingFlags.NonPublic);

            try
            {
                EventInfo projectChangedEvent = typeof(EditorApplication).GetEvent("projectChanged");
                projectChangedEvent.AddEventHandler(null, Delegate.CreateDelegate(projectChangedEvent.EventHandlerType, null, ResetAllScenesMethod));
                //EditorApplication.projectChanged += NGScenesWindow.ResetAllScenes;
            }
            catch
            {
                FieldInfo projectWindowChangedField = UnityAssemblyVerifier.TryGetField(typeof(EditorApplication), "projectWindowChanged", BindingFlags.Static | BindingFlags.Public);
                if (projectWindowChangedField != null)
                {
                    projectWindowChangedField.SetValue(null, Delegate.Combine((Delegate)projectWindowChangedField.GetValue(null), Delegate.CreateDelegate(projectWindowChangedField.FieldType, null, ResetAllScenesMethod)));
                }
                //EditorApplication.projectWindowChanged += NGScenesWindow.ResetAllScenes;
            }
        }