Search Issue Tracker
Won't Fix
Won't Fix in 2022.3.X
Votes
0
Found in
2021.3.27f1
2022.3.2f1
Issue ID
UUM-39993
Regression
No
Conditional compilation directives like #if UNITY_EDITOR are ignored when building the project
Reproduction steps:
1. Open the “compilerErrorOnBuild“ project
2. Open the “SampleScene“ scene
3. Build the project
4. Build And Run the project using the Build Settings window
Expected result: Both builds are successful
Actual result: A build fails due to an error caused in `OnValidate` which is inside a `#if UNITY_EDITOR` directive
Reproduced in: 2020.3.48f1, 2021.3.27f1, 2022.3.2f1
Not reproduced in: 2023.1.0a1, 2023.1.0f1, 2023.2.0a19
Already fixed in: 2023.1.0a1
Reproduced using: Windows 10 (by the reporter), Windows 11, macOS 13.4 (Intel)
Note: The reproduction was inconsistent. E.g. the issue went away after performing a “Reimport All”
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Texture2D hash changes inside of an AssetBundle when rebuilding a SpriteAtlas bundle with an empty AssetPostprocessor Script enabled
- Aniso Level still applies when Generate MipMap is disabled in Texture Import Settings
- Mipmap Limit Groups long names are not truncated when creating a new Mipmap Limit Group with a long name
- “ArgumentException: Invalid double parameter.” error is thrown when Infinity is typed into the Fixed Timestep field
- GameObject becomes gray when using HDRP and STP together on macOS
Resolution Note:
OnValidate is called when Scene is loaded.
When we build players, we also first load the scenes in the Editor to know what Assets are used so we only copy what is needed.
OnValidate are only called in the Editor, so thats why the `#if UNITY_EDITOR` do not exclude ty8s c
Resolution Note (2022.3.X):
OnValidate is called when Scene is loaded.
When we build players, we also first load the scenes in the Editor to know what Assets are used so we only copy what is needed.
OnValidate are only called in the Editor, so thats why the `#if UNITY_EDITOR` do not exclude ty8s c