예제 #1
0
        static void Prefix(int id, WindowFunction func, GUIContent title)
        {
            IMGUIBlocker.BlockIfConfigured(func, id);
            IMGUIPluginTranslationHooks.HookIfConfigured(func);

            AutoTranslationPlugin.Current.Hook_TextChanged(title, false);
        }
예제 #2
0
        public static void InstallIMGUIBasedPluginTranslationHooks(Assembly assembly, bool final)
        {
            if (Settings.EnableIMGUI && !_installedAssemblies.Contains(assembly))
            {
                if (final)
                {
                    IMGUIPluginTranslationHooks.ResetHandledForAllInAssembly(assembly);
                }

                var types = assembly.GetTypes();
                foreach (var type in types)
                {
                    try
                    {
                        if (typeof(MonoBehaviour).IsAssignableFrom(type) && !type.IsAbstract)
                        {
                            var method = type.GetMethod("OnGUI", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
                            if (method != null)
                            {
                                IMGUIPluginTranslationHooks.HookIfConfigured(method);
                            }
                        }
                    }
                    catch (Exception e2)
                    {
                        XuaLogger.AutoTranslator.Warn(e2, "An error occurred while hooking type: " + type.FullName);
                    }
                }

                if (final)
                {
                    _installedAssemblies.Add(assembly);
                }
            }
        }