@@ -31,16 +31,54 @@ public static class MyScript {
3131 public static void Main () {
3232 Debug .Log (" Hello, world!" );
3333 }
34+
35+ public static void Unload () {
36+ // Unload and unpatch everything before reloading the script
37+ }
3438}
3539```
3640
41+ ### Reloading scripts
42+
43+ ScriptLoader automatically detects changes in the scripts and reloads them.
44+
45+ In order to make your script reloadable, ** you must implement ` static void Unload() ` ** method that cleans up any used resources.
46+ This is done because of Mono's limitation: you cannot actually unload any already loaded assemblies in Mono. Because of that, you should
47+ clean up your script so that the newly compiled script will not interfere with your game!
48+
49+ ### Specifying metadata
50+
51+ You can specify metadata * at the very start of your script* by using the following format:
52+
53+ ``` csharp
54+ // #name Short name of the script
55+ // #author ghorsington
56+ // #desc A longer description of the script. This still should be a one-liner.
57+ // #ref ${Managed}/UnityEngine.UI.dll
58+ // #ref ${BepInExRoot}/core/MyDependency.dll
59+
60+ using UnityEngine ;
61+ .. .
62+ ```
63+
64+ The ` ref ` tag is special: ScriptLoader will automatically load any assemblies specified with the tag.
65+ The path is relative to the ` scripts ` folder, but you can use ` ${Folder} ` to reference some special folders.
66+
67+ Currently the following special folders are available:
68+
69+ * ` Managed ` -- path to the game's Managed folder with all the main DLLs
70+ * ` Scripts ` -- path to the ` scripts ` folder
71+ * ` BepInExRoot ` -- path to the ` BepInEx ` folder
72+
73+ ** WIP** : At the moment, all tags but ` ref ` have no effect. A GUI is planned to allow to disable any scripts.
74+
3775### Compilation errors
3876
3977At this moment the compilation errors are simply written to the BepInEx console.
4078
4179## TODO
4280
43- * [ ] Script reloading
44- * [ ] Specifying script metadata (name, description, DLL dependencies)
81+ * [x ] Script reloading
82+ * [x ] Specifying script metadata (name, description, DLL dependencies)
4583* [ ] Maybe a UI?
4684* [ ] Optionally an ability to locate and use ` csc ` to compile scripts when mcs cannot be used
0 commit comments