Search Issue Tracker
Fixed in 2021.1.X
Fixed in 2020.3.X
Votes
1
Found in
2020.1.0a7
2020.2
2020.2.0b2
Issue ID
1279339
Regression
Yes
Unity doesn't recognise the script as Monobehaviour script when there's a grave accent in an #if false block inside a namespace
How to reproduce:
1. Open the attached "ScriptBreakingUnity" project
2. In the Project window select the "breakit" script
3. Open the Inspector (Window->General->Inspector)
Expected results: There's no "No MonoBehaviour scripts in the file, or their names do not match the file name." message
Actual results: There's a "No MonoBehaviour scripts in the file, or their names do not match the file name." message
Reproducible with: 2020.1.0a7, 2020.1.6f1, 2020.2.0b3
Not reproducible with: 2018.4.27f1, 2019.4.11f1, 2020.1.0a6
Notes:
- 2020.1.0a7 is the first version where the issue appears when creating a new project (not upgrading/downgrading)
- Upgrading a project with the script up to Unity 2020.1.0a14 will not reproduce the issue if it wasn't there initially
- When downgrading a project that has the issue to Unity 2020.1.0a2 or later will keep the issue around but resetting packages sometimes fixes it
- If the #if block with the grave accent is not inside a namespace Unity will not throw any errors and will recognise the script as MonoBehaviour
- If the #if block is set to true, the Console will throw the "Unexpected character" error and the Editor will accept the script as MonoBehaviour script
Comments (2)
-
weber-jaroslaw-dmm
Jan 06, 2022 03:52
still happens in unity 2020 LTS
-
Peter77
Sep 23, 2020 05:01
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
- Crash on GUIState::BeginOnGUI when a Node is opened in a custom graph editor in Play Mode
- USS selector is duplicated when it is added to an element, the action is undone, and then another selector is clicked
- Text and dropdown icon are not aligned in UI Toolkit Samples
- [RenderGraph] SSAO pass in URP RenderGraph uses DontCare flag after changing the Render Scale resulting in a black screen or artifacts
- Player with IL2CPP Scripting Backend crashes when calling Application.Quit() while a thread is running
Resolution Note (fix version 2021.1):
Fixed in 2021.1.0a2
Resolution Note (fix version 2020.3):
Fixed in Unity 2020.3.27f1