Search Issue Tracker
By Design
Votes
1
Found in
2022.2.0b11
2023.1.0a14
Issue ID
UUM-16718
Regression
Yes
Partial MonoBehaviour script can not be attached to a GameObject when another one exists with the same file and class name
How to reproduce:
1. Open the attached project (Part.zip)
2. In the Project panel navigate to the "Scripts" folder
3. Drag the "Part" script onto any GameObject in the Hierarchy
Expected result: The script is added to the GameObject
Actual result: The editor opens a "Can't add script" window informing that the script could not be attached
Reproducible with: 2022.2.0a5, 2022.2.0b11, 2023.1.0a14
Not reproducible with: 2020.3.40f1, 2021.3.12f1, 2022.1.19f1, 2022.2.0a4
Reproducible on: Windows 10, Ubuntu 20.04
Note: The script being attached has to have a partial class and another script with the same file and class name in another folder
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
- IndexOutOfRangeException occurs when entering "<a></a>" tags in a TextMeshPro UI field
- Numeric property drag cursor gets enabled in the Inspector Preview window when the window is above numeric properties
- UI elements become unusable due to Object and Text Fields being set to empty/"0" when clicking "Reset" on their Components
- Scene Asset is not attached to a Lighting Data Asset for a URP Package Sample Scene
- Gizmos are not rendered for the Base Camera when using Camera Stacking
Resolution Note:
This is by design.
The workarround is having the partial classes having different filenames. While the partial class you want to use have the same filename as the class name. So only the class that matches the filename is useable.