Skip to content

Commit 9c5a321

Browse files
claudeNormandErwan
authored andcommitted
docs: update README for DocFxForUnity.csproj setup and UNITY_MANAGED_PATH
- Add DocFxForUnity.csproj to the list of files to copy in setup step 2, with a note on renaming and updating docfx.json - Replace the outdated "Assets > Open C# Project" troubleshooting tip with instructions matching the committed .csproj approach - Add a "Unity managed DLLs not found" FAQ entry describing the three-step resolution order (env var → lib/ → OS glob) - Add a new "Advanced: UNITY_MANAGED_PATH" section with per-OS paths and shell snippets for overriding the auto-detected Unity version - Update xref version examples from 2017/2018/2019 to current versions https://claude.ai/code/session_01DctbQWKKrBNCfvBuKsu5ad
1 parent 4bb0022 commit 9c5a321

1 file changed

Lines changed: 46 additions & 4 deletions

File tree

README.md

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,20 @@ online: <https://normanderwan.github.io/DocFxForUnity/>. It references both C# A
2020
## Setup your documentation
2121

2222
1. [Install DocFX](https://dotnet.github.io/docfx/tutorial/docfx_getting_started.html#2-use-docfx-as-a-command-line-tool).
23-
2. Copy the `Documentation/` folder to your Unity project:
23+
2. Copy the `Documentation/` folder and `DocFxForUnity.csproj` to your Unity project:
2424

2525
```diff
2626
.
2727
├── Assets
28+
+ ├── DocFxForUnity.csproj
2829
+ ├── Documentation
2930
├── Package
3031
├── ProjectSettings
3132
└── README.md
3233
```
3334

35+
You can rename `DocFxForUnity.csproj` to match your project — just update the filename in `Documentation/docfx.json` under `metadata[0].src[0].files` accordingly.
36+
3437
3. Edit the following properties in `Documentation/docfx.json`, keep the others as it is:
3538

3639
```javascript
@@ -136,25 +139,64 @@ details.
136139

137140
- DocFX outputs: `Warning:[ExtractMetadata]No project detected for extracting metadata.`
138141

139-
Solution: On Unity, click [Asset > Open C# Project](https://docs.microsoft.com/fr-fr/visualstudio/cross-platform/media/vstu_open-csharp-project.png?view=vs-2019) to generate the required `.csproj`.
142+
Solution: Make sure you copied `DocFxForUnity.csproj` (or your renamed version) to the root of your Unity project, and that the filename matches the entry in `Documentation/docfx.json` under `metadata[0].src[0].files`.
140143

141144
- DocFX outputs: `Warning:[ExtractMetadata]No metadata is generated for Assembly-CSharp,Assembly-CSharp-Editor.`
142145

143-
Solution: Make sure your included your namespace in `Documentation/filterConfig.yml`:
146+
Solution: Make sure you included your namespace in `Documentation/filterConfig.yml`:
144147

145148
```yaml
146149
- include:
147150
uidRegex: ^Your\.Namespace1
148151
type: Namespace
149152
```
150153

154+
- MSBuild outputs: `Unity managed DLLs not found.`
155+
156+
This means DocFX could not locate Unity's managed DLLs. It looks in three places, in order:
157+
1. The `UNITY_MANAGED_PATH` environment variable (see below).
158+
2. `lib/UnityEngine/` at the project root (populated automatically by the CI workflow).
159+
3. The default Unity Hub installation directory for your OS.
160+
161+
If Unity Hub is installed at a non-default location, or you want to target a specific Unity version, set `UNITY_MANAGED_PATH` (see *Advanced: `UNITY_MANAGED_PATH`* below).
162+
151163
- If you want to reference a specific version of Unity, change this line on your `docfx.json`:
152164

153165
```json
154166
"xref": [ "https://normanderwan.github.io/UnityXrefMaps/<version>/xrefmap.yml" ],
155167
```
156168

157-
where `<version>` is a Unity version in the form of `YYYY.x` (*e.g.* 2017.4, 2018.4, 2019.3).
169+
where `<version>` is a Unity version in the form of `YYYY.x` (*e.g.* 2022.3, 2023.2, 6000.0).
170+
171+
## Advanced: `UNITY_MANAGED_PATH`
172+
173+
By default, `DocFxForUnity.csproj` auto-detects the Unity managed DLLs from the standard Unity Hub installation directory. Set `UNITY_MANAGED_PATH` when you need to:
174+
175+
- Use a Unity version installed at a non-default location.
176+
- Pin to a specific version when multiple Unity versions are installed.
177+
- Work without Unity Hub (standalone Unity install).
178+
179+
Point it to the `UnityEngine` subfolder inside your Unity installation's `Managed` directory:
180+
181+
| OS | Example path |
182+
|----|-------------|
183+
| Windows | `C:\Program Files\Unity\Hub\Editor\6000.0.73f1\Editor\Data\Managed\UnityEngine` |
184+
| macOS | `/Applications/Unity/Hub/Editor/6000.0.73f1/Unity.app/Contents/Managed/UnityEngine` |
185+
| Linux | `~/Unity/Hub/Editor/6000.0.73f1/Editor/Data/Managed/UnityEngine` |
186+
187+
Set it in your shell before running DocFX:
188+
189+
```bash
190+
# macOS / Linux
191+
export UNITY_MANAGED_PATH="/Applications/Unity/Hub/Editor/6000.0.73f1/Unity.app/Contents/Managed/UnityEngine"
192+
docfx Documentation/docfx.json --serve
193+
```
194+
195+
```powershell
196+
# Windows (PowerShell)
197+
$env:UNITY_MANAGED_PATH = "C:\Program Files\Unity\Hub\Editor\6000.0.73f1\Editor\Data\Managed\UnityEngine"
198+
docfx Documentation/docfx.json --serve
199+
```
158200

159201
## Disclaimer
160202

0 commit comments

Comments
 (0)