Configuration
In addition to the settings available through the editor UI, there are additional, more advanced, settings available in the hot-reload-config.json
file that you can create in the root of your project (one directory above the "Assets" folder).
{
"externalSolutions": ["../src/ExternalSlnDir/External.sln"],
"additionalSourceDirectories": ["../src/SharedUtility"],
"projectBlacklist": ["../src/ExternalSlnDir/UnitTests/UnitTests.csproj"],
"projectExclusionRegex": ".*Tests$",
"polyfillSourceFiles": ["PolyFills/IndexRange.cs"],
"customServerExecutables": {
"win-x64": "/path/to/CodePatcherCLI.exe",
"linux-x64": "/path/to/CodePatcherCLI",
"osx-x64": "/path/to/HotReload.app.zip"
},
"excludeAllAnalyzers": true
}
When you modify hot-reload-config.json
do the following to ensure the config changes are applied:
- Recompile Unity Editor
- Restart Hot Reload server
All fields in this file are optional. Following is the explanation on each of the options:
externalSolutions
Useful if you have an extenal compilation pipeline that compliles assemblies that are used in the unity project. Adding them here will make Hot Reload able to handle code changes made to those solutions.
The file paths to external solutions. Paths shall be specified relative to the unity project path.
Consider the following example:
UnityProject
|_ UnityProject.sln
src
|_ ExternalSlnDir
|\_ External.sln
here the path would be ../src/ExternalSlnDir/External.sln
additionalSourceDirectories
The file paths to additional source directories that are not already part of a solution folder or its sub folders. Paths shall be specified relative to the unity project path.
Consider this example:
UnityProject
|_ UnityProject.sln
src
|_ ExternalSlnDir
|_ External.sln
|_ External.csproj <- uses Foo.cs
|_ SharedUtility
|_ Foo.cs
In such a case the path ../src/SharedUtility
needs to be specified as an additional source directory.
This is mainly to ensure that the file watcher listens to all c# files that are related to the unity project.
The Assets/ and Packages/ folders and all paths to local packages specified in the Packages/manifest.json are already covered.
projectBlacklist
The file paths to project files that Hot Reload should ignore. Paths shall be specified relative to the unity project path. This can reduce memory usage and startup times but can also prevent issues if a project uses tools that are not supported by Hot Reload (e.g. IL-Weaving)
Consider this example:
UnityProject
|_ UnityProject.sln
src
|_ ExternalSlnDir
|_ External.sln
|_ UnitTests
|\_ UnitTests.csproj
here the path would be ../src/ExternalSlnDir/UnitTests/UnitTests.csproj
projectExclusionRegex
Similar to projectBlacklist, but excludes project where the project name matches the given regex.
Example: .\*Tests$
would exclude all projects that end with Tests
polyfillSourceFiles
The file paths to source files that should get added to all unity .csproj files. Use this is you e.g. use a csc.rsp to include polyfill csharp files when compiling the script assemblies Paths shall be specified relative to the unity project path.
Consider this example:
UnityProject
|_ UnityProject.sln
PolyFills
|_ IndexRange.cs
here the path would be PolyFills/IndexRange.cs
customServerExecutables
Path to custom server executables that should be used instead of downloading them from the usual sources. This can be useful if you want to commit the server executables to your repository so that there is no extenal download required if you use Hot Reload in a bigger team.
{
"customServerExecutables": {
"win-x64": "/path/to/CodePatcherCLI.exe",
"linux-x64": "/path/to/CodePatcherCLI",
"osx-x64": "/path/to/HotReload.app.zip"
}
}
The paths shall be specified relative to the unity project path or as absolute paths.
Whenever you update the Hot Reload package you need to download the updated binaries.
Version is the package version with '.' replaced with '-'. So for version 1.5.0 the urls you need are: https://hot-reload.b-cdn.net/releases/1-5-0/server/win-x64/CodePatcherCLI.exe (opens in a new tab) https://hot-reload.b-cdn.net/releases/1-5-0/server/linux-x64/CodePatcherCLI (opens in a new tab) https://hot-reload.b-cdn.net/releases/1-5-0/server/osx-x64/HotReload.app.zip (opens in a new tab)
The version can be found in HotReload/Runtime/PackageConst.cs
The constant "ServerVersion" is the version you need to use.
excludeAllAnalyzers
By default Hot Reload will run all analyzers that Unity is also running. However, there are cases where you simply want to exclude all analyzers. E.g. when they are mostly used for non-essential diagnostics. This can speed up hot reload times and overall startup times of the Hot Reload server. However, use this with caution. If you are using source generators, those will be disabled as well and this can lead to Hot Reload not working correctly.