예제 #1
0
        private static void LoadPlugins(Logging.IPALogger logger)
        {
            string pluginDirectory = Path.Combine(Environment.CurrentDirectory, "Plugins");

            // Process.GetCurrentProcess().MainModule crashes the game and Assembly.GetEntryAssembly() is NULL,
            // so we need to resort to P/Invoke
            string exeName = Path.GetFileNameWithoutExtension(AppInfo.StartupPath);

            logger.Debug(exeName, "IPA");
            _Plugins = new List <IPlugin>();

            if (!Directory.Exists(pluginDirectory))
            {
                return;
            }

            string[] files = Directory.GetFiles(pluginDirectory, "*.dll");
            foreach (var s in files)
            {
                _Plugins.AddRange(LoadPluginsFromFile(Path.Combine(pluginDirectory, s), exeName, logger));
            }

            // DEBUG
            logger.Debug($"Running on Unity {UnityEngine.Application.unityVersion}", "IPA");
            logger.Debug($"Loading plugins from {pluginDirectory} and found {_Plugins.Count}", "IPA");
            foreach (var plugin in _Plugins)
            {
                logger.Debug($"{plugin.Name}: {plugin.Version}", "IPA");
            }
        }
예제 #2
0
        void Awake()
        {
#if DEBUG
            logger.Debug("Awake()", "IPA");
#endif
            DontDestroyOnLoad(gameObject);

            plugins = new CompositePlugin(PluginManager.GetPlugins(logger), logger);
            plugins.OnApplicationStart();

            pluginLoggers = FindObjectsOfType <PluginLogger>();
            foreach (PluginLogger pluginLogger in pluginLoggers)
            {
                pluginLogger.Message += logger.Log;
            }

            SceneManager.activeSceneChanged += OnSceneChanged;
        }