Search Issue Tracker
Fixed in 2022.2.X
Votes
0
Found in
2020.1.0a5
2020.3
2020.3.26f1
2021.2
2022.1
2022.2
Issue ID
1398029
Regression
Yes
"Can't add script" error is thrown when a Preprocessor Command block contains string concatenations
How to reproduce:
1. Open the attached project "scriptRepro"
2. Open the scene "SampleScene" (Assets/Scenes/SampleScene.unity)
3. In the Project window, select the script "Test" (Assets/Test.cs)
4. In the Hierarchy window, locate the GameObject "ClickMe" and drag the script onto it
Expected result: The script is added to the GameObject
Actual result: A "Can't add script" window pops up
Reproducible with: 2020.1.0a5, 2020.3.27f1, 2021.2.10f1, 2022.1.0b6, 2022.2.0a2
Not reproducible with: 2019.4.36f1, 2020.1.0a4, 2022.2.0a3
Full message:
Can't add script component 'Test' because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match.
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
- Articulation Body with 'Revolute' Joint Type has erratic behavior when Upper Limit is set to above 360
- WebGL Player fails to render Scene when Terrain with Detail Mesh is added and WebGPU Graphics API is used
- Inconsistent errors are logged when different types are passed into the Query "Q<>" method in UIToolkit and the ancestor VisualElement is null
- Crash on GetMaterialPropertyByIndex when opening a specific Scene
- Discrepancies in the styling are present when using a TSS file instead of a USS file in custom EditorWindow
Resolution Note (fix version 2022.2):
Fixed in: 2022.2.0a3