Search Issue Tracker
By Design
Votes
0
Found in
2019.3.0b4
2020.1
2020.1.0a11
Issue ID
1195655
Regression
Yes
Can't add a script as a component when there are two classes with the same Name in the script but in different Namespaces
Can't add a script as a component when there are two classes with the same Name (one is a MonoBehaviour, the other isn't) in the same script , but in different Namespaces
Reproduction steps:
1. Open "PROJECT TO IMPORT ASSETS.zip" project
2. Try to add the "BreaksParser.cs" script as a component
3. A pop-up appears "Can't add script"
Expected Result: Script is added as a component as it has a valid MonoBehaviour in its second Namespace
Actual Result: Can't add a script as a component when there are two classes with the same Name, but in different Namespaces
Reproduced with: 2020.1.0a12, 2019.3.0b10, 2019.3.0b9, 2019.3.0b8, 2019.3.0b7, 2019.3.0b5, 2019.3.0b4
Did not reproduce on: 2019.3.0b3, 2019.3.0b1, 2019.3.0a1, 2019.2.12f1, 2018.4.12f1, 2017.4.34f1
Warning:
Class BreaksParser can not exist in multiple namespaces in the same file, even if one is excluded with preprocessor directives. Please move these to separate files if this is the case.
Note:
The issue doesn't repro in 2019.3.0b4 if last opened version was lower
-
tellmandscouk
Apr 14, 2021 17:41
tellmandscouk.com
-
tellmandscouk
Apr 14, 2021 17:12
I tried to add the "BreaksParser.cs" as a component, but there I didn't get the pop-up.
-
RichHazelnut
Jun 16, 2020 10:10
Awesome content https://www.telldunkin.me/
-
ginine12333
May 18, 2020 08:56
The more information about script as a component when there are two classes with the same name. I know about this site and https://bestwritingsclues.com/reviews/grademiners-review/ has been updating us about more college writing essays and grade reviews.
-
sebas77
Apr 15, 2020 16:42
I don't know if this comment will be ever read, but this compiler warning is indeed generated also when monobehaviours are not used:
https://forum.unity.com/threads/annoying-compiler-warning-i-dont-think-is-correct.823116/
-
hellowill89
Dec 05, 2019 17:46
What will happen if the warning is ignored? Will anything break or be broken in the future?
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
- Matching Selectors list not updating correctly with element's pseudo-state updates
- [Android] Crash on vendor/lib64/egl/libGLES_mali.so when Graphics Jobs(Experimental) is disabled and the Player is running on the Google Pixel 6 with the March security patch installed
- Profiler does not profile after building the Project with Autoconnect Profiler Option enabled
- Editor slows down when selecting a script with the [HideInInspector] attribute on arrays with dynamic values
- [XR] Custom Pass not working as intended with Single Pass Instanced when XR is initialized after runtime start
Resolution Note:
Currently this is by design. Only have one namespace and type in your file, if it inherits from MonoBehavior or ScriptableObject.
We have notified our documentation team about missing documentation in this area.