Exemplo n.º 1
0
        public void Initialize()
        {
            Current = this;

            Settings.Configure();

            HooksSetup.InstallHooks(Override_TextChanged);

            AutoTranslateClient.Configure();

            _symbolCheck = TextHelper.GetSymbolCheck(Settings.FromLanguage);

            LoadTranslations();

            // start a thread that will periodically removed unused references
            var t1 = new Thread(RemovedUnusedReferences);

            t1.IsBackground = true;
            t1.Start();

            // start a thread that will periodically save new translations
            var t2 = new Thread(SaveTranslationsLoop);

            t2.IsBackground = true;
            t2.Start();
        }
        public void Initialize()
        {
            Current        = this;
            Logger.Current = new ConsoleLogger();

            Settings.Configure();

            if (Settings.EnableConsole)
            {
                DebugConsole.Enable();
            }

            HooksSetup.InstallHooks(Override_TextChanged);

            try
            {
                _endpoint = KnownEndpoints.FindEndpoint(Settings.ServiceEndpoint);
            }
            catch (Exception e)
            {
                Logger.Current.Error(e, "An unexpected error occurred during initialization of endpoint.");
            }

            _symbolCheck = TextHelper.GetSymbolCheck(Settings.FromLanguage);

            LoadTranslations();

            // start a thread that will periodically removed unused references
            var t1 = new Thread(MaintenanceLoop);

            t1.IsBackground = true;
            t1.Start();

            // start a thread that will periodically save new translations
            var t2 = new Thread(SaveTranslationsLoop);

            t2.IsBackground = true;
            t2.Start();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Loads the plugin with the specified environment.
        /// </summary>
        /// <param name="config"></param>
        public static IMonoBehaviour LoadWithConfig(IPluginEnvironment config)
        {
            if (!_loaded)
            {
                _loaded = true;
                PluginEnvironment.Current = config;

#if MANAGED
                var obj = new GameObject("___XUnityAutoTranslator");
                obj.hideFlags = HideFlags.HideAndDontSave;
                Plugin        = obj.AddComponent <AutoTranslationPlugin>();
                MonoBehaviour = Plugin;
                GameObject.DontDestroyOnLoad(obj);
#else
                Plugin = new AutoTranslationPlugin();
                var obj = new GameObject("___XUnityAutoTranslator");
                obj.hideFlags = HideFlags.HideAndDontSave;
                MonoBehaviour = obj.AddComponent <AutoTranslatorProxyBehaviour>();
                GameObject.DontDestroyOnLoad(obj);
#endif
            }
            return(Plugin);
        }