AutoReload

版本 v1.0.2·更新於 2026-09-09

Automatically reloads plugins by watching BepInEx/plugins/ for file changes. For developers.

模組介紹 作者原文

AutoReload

A BepInEx 5 plugin that automatically reloads plugins by watching BepInEx/plugins/ for file changes.

[!WARNING]

I have been informed that the FileSystemWatcher may work terribly on Windows. This plugin relies on FileSystemWatcher working properly. If you are having issues with it, try running under Linux.

Also, if BepInEx is not configured to hide plugin manager gameObject, this plugin will not work properly. Set HideManagerGameObject to true in BepInEx.cfg if this plugin is not working. This setting is enabled by default in BepInExPack for PEAK.

Implementing Support

To make your plugin work with reloading, it must implement the OnDestroy method in the main plugin class to clean up after itself. An example of a good plugin:

[BepInAutoPlugin]

public partial class Plugin: BaseUnityPlugin

{

void Awake()

{

// Apply all hooks

MonoDetourManager.InvokeHookInitializers(typeof(Plugin).Assembly);

Log.LogInfo($"Plugin {Name} is loaded!");

}

void OnDestroy()

{

// Dispose all hooks

DefaultMonoDetourManager.Instance.Dispose();

Log.LogInfo($"Plugin {Name} unloaded!");

}

}

[!TIP]

The above plugin uses Hamunii.BepInEx.AutoPlugin for the [BepInAutoPlugin] attribute, and MonoDetour for hooking.

Limitations

Fixable Limitations

  • If mod A and B are both reloaded, and A depends on B, A will reference the first ever loaded version of B.
  • AutoReload would need to detect that A depends B, and rewrite A's references to B to reference the latest B assembly before A is reloaded.
  • Currently this can be worked around by using ILRepack or ILRepack.Lib.MSBuild.Task.
  • Reloaded plugins don't retain any state.

Runtime Limitations

  • Old assemblies are never actually unloaded because it's impossible.

Alternatives

-

  • UnityHotReload preserves the existing runtime state by redirecting all active references to the original type definitions.

-

  • AutoReload is a hard fork of this. For comparison, see the Credits below.

Credits

This is a hard fork of BepInEx.Debug ScriptEngine which dramatically changes how the plugin works.

Main changes are:

  • scripts/ directory is gone
  • assemblies are reloaded from plugins/
  • LoadOnStart option is gone
  • FileSystemWatcher option is gone, always enabled
  • AutoReloadDelay option is gone
  • ReloadKey option is gone
  • IncludeSubdirectories option is gone, always enabled
  • Only "file changed" and "file renamed" events are listened to
  • DumpAssemblies option is gone, always enabled
  • This is because you can get debug symbols this way

安裝與使用 安裝:BepInEx 外掛

  1. 本站下載的壓縮包就是模組本體,通常是 BepInEx 外掛(解壓後得到 .dll 或外掛資料夾)。
  2. 建議流程:用社群模組管理器(如 r2modman)選中本遊戲後匯入該模組,管理器會自動裝好 BepInEx 前置並處理依賴。
  3. 手動流程:先在遊戲目錄裝好 BepInEx 載入器,再把解壓出的 .dll 或外掛資料夾放進 BepInEx/plugins/。
  4. 啟動遊戲,BepInEx 控制台會列印載入日誌;確認這個模組出現在日誌裡即為安裝成功。

帶「前置依賴」的模組需要一併安裝,否則不會載入。功能開關通常在遊戲內或外掛自帶的設定檔裡調整。

前置依賴

下面這些內容需要先安裝,否則該模組不會生效:

BepInEx-BepInExPack_PEAK

檔案與校驗

檔案名稱
AutoReload-1.0.2.zip
檔案大小
28.2 KiB