Search Issue Tracker
Won't Fix
Under Consideration for 2021.3.X, 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
- “Remove Unused Overrides” available on not loaded Scene and throws “ArgumentException: The scene is not loaded” warning
- Adaptive Probe Volume occlusion edge is calculated incorrectly when viewing probes near geometry edges
- Sampling a texture using an HLSL file throws shader errors and the code does not compile
- "Graphics.CopyTexture called with null source texture" error when Base Camera of an Overlay Camera is removed with DX11 Graphics API and Compatibility Mode enabled
- WebGL sends wrong value with large numbers when SendMessage function is used
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