'Scripting define symbol code is not skipping the code in unity C#
I want to skip a particular code by defining scripting define symbol but sadly it is not working.
#if VST
using AW.VegetationStudio;
#endif
Like in the above code in my project VST is not defined in scripting define symbols but it is still showing error in entering lines.
Solution 1:[1]
As of 2021.3.1f1, I had a similar issue with Scripting Define Symbols. So, I leave workarounds I found here. (The following things are observed on macOS 12.3.1, by the way.)
Unity Editor Behaviours
what I can see with Project Settings view - Scripting Define Symbols section on Unity Editor is that every time clicking on the Apply button under the input field, the second last edit is reflected on the in csproj files, which is where VS reads the defined symbols from.
However, the modification is not saved to /ProjectSettings/ProjectSettings.asset
file by the Apply button. (csproj files are (re)generated based on this file, btw.) The operations that save the change to the ProjectSettings.asset
file are [File - Save Project] from the Unity Editor menu, or restarting Unity Editor.
Workarounds
Based on such current behaviours of Unity Editor, there are two ways to make sure the symbol definition updates are certainly reflected on ProjectSettings.asset
file and all the csproj files.
- Close Unity Editor (changes are saved to
ProjectSettings.asset
) - Open Unity Editor (csproj files are regenerated)
Or,
- [File - Save Project] or [File - Save Project] from the Unity Editor menu (changes are saved to
ProjectSettings.asset
) - Press + button under Project Settings view - Scripting Define Symbols section on Unity Editor, and leave it empty
- Click the Apply button (csproj files are regenerated)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |