Skip to content

Commit

Permalink
Update the build documentation with a note about how to set preproces…
Browse files Browse the repository at this point in the history
…sor macros
  • Loading branch information
ericf authored and ericf committed Aug 12, 2024
1 parent 2c6e25b commit 531e16f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions docs/03-github/04-builder.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,30 @@ that directory. This action must be done before running the game-ci/unity-builde
echo "token = \"${{ secrets.NPM_TOKEN }}\"" >> .upmconfig.toml
```

## Using preprocessor macros

If needed, Unity preprocessor directives can be set by adding a step to the build.

```yaml
steps:
- name: Apply csc.rsp (pre-processor symbols)
run: echo -define:MY_SYMBOL >> Assets/csc.rsp
```

To avoid warnings about "unapplied changes", add `Assets/csc.rsp` in your `.gitignore`

Once set, you can then reference these preprocessor directives in code:

```c
void Start() {
#if MY_SYMBOL
GetComponent<TMP_Text>().text = "I have a symbol!";
#else
GetComponent<TMP_Text>().text = "I do not have a symbol...";
#endif
}
```

## Complete example

A complete workflow that builds every available platform could look like this:
Expand Down

0 comments on commit 531e16f

Please sign in to comment.