Search Issue Tracker
Duplicate
Votes
0
Found in
5.6.2p3
Issue ID
942001
Regression
Yes
A particular script is not recognized as a MonoBehaviour
The script seems to be not recognized as MonoBehaviour if it is in a custom namespace AND there is a preprocessor directive:
#if UNITY_EDITOR
#else
#endif
If the empty line between #else and #endif is removed OR class is moved out of the custom namespace, everything works fine again.
To reproduce:
1. Open the project, attached by the tester (unrecognizedClass.zip)
2. Add test.cs script to any game object in the scene
Expected: a script is recognized as a MonoBehaviour regardless of whether it is in a custom namespace and there is a particular preprocessor directive
Actual: a script cannot be added to the game object, even though it is a MonoBehaviour and class name is the same as the script's name, due to the preprocessor directives and custom namespace
Reproduced in 5.5.0b5, 5.5.4p2, 5.6.2p3, 2017.1.0p4, 2017.2.0b8, 2017.3.0a4
Did not reproduce 5.4.5p4, 5.5.0b4
Regression introduced in 5.5.0b5
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
- TMP Input Field becomes not interactable when pasting a long text
- CSS is not applied when using USS type selector "GridBackground"
- Player .exe remains open as a background task after closing it when Active Input Handling is set to "Input System Package (New)"
- Exception block is being rewritten to throw an incorrect number of exceptions when running a project built using IL2CPP Scripting Backend
- [Android] [Vulkan] Warning "AndroidPlayer "<device>" VULKAN: GENERAL WARNING: The following warning was triggered: VKDBGUTILWARN003." spammed every frame when the application is actively running on a device
This is a duplicate of issue #927189