Search Issue Tracker
Won't Fix
Won't Fix in 6000.6.X
Votes
0
Found in
6000.0.74f1
6000.3.15f1
6000.4.6f1
6000.5.0b7
6000.6.0a4
Issue ID
UUM-141893
Regression
No
Scripts with null Components on GameObjects are not removed when calling GameObjectUtility.RemoveMonoBehavioursWithMissingScript
How to reproduce:
1. Open the attached “IN-142438“ project
2. Open the “scene“ scene
3. In the Hierarchy, select the “background“ GameObject
4. In the Inspector, observe and note the Components of the “background“ GameObject
5. In the Editor menu bar, select “GameObjectUtility“ (RemoveNullComponents > GameObjectUtility)
6. Repeat steps 3 and 4
Actual result: The (Script) null Component has not been removed from the “background“ GameObject
Expected result: The (Script) null Component has been removed from the “background“ GameObject
Reproducible with: 2023.1.0a1, 6000.0.74f1, 6000.3.15f1, 6000.4.6f1, 6000.5.0b7, 6000.6.0a4
Reproducible on: Windows 11
Not reproducible on: No other environments tested
Note: Testing 6000.4 to 6000.6 streams required minor adjustments to the script calling GameObjectUtility.RemoveMonoBehavioursWithMissingScript because of the changes made to EntityID
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
- AdaptiveLOD sample has missing prefabs and throws missing prefab errors when the AdaptiveLOD sample is imported and the AdaptiveLOD scene is opened
- Error "transform.position assign attempt for 'x' is not valid" is logged when Moving Game Object to View while a Scene is multi selected
- [Desktop] Plastic move detection mixes up identical files
- SVG Icon has tessellation issues in "Antialiased Arc Encodings", ok with "Basic Triangulation"
- "You may not pass null objects" and "Maximized serialized file backup not found" errors are thrown when maximizing and minimizing docked Multiplayer Play Mode window after Multiplayer Play Mode package is uninstalled
Resolution Note:
Looking at the user project, the references in the scene file is of type "MonoScript". MonoScripts tends to be serialized into a scene file for:
- Special case MonoBehaviours, authored by Unity, with a native backing (e.g. Entity’s SubScene)
- Script references from Unity 4.x and older
We couldn't figure out how these references ended up in the scene file in the first place, but the assembly name points towards that these were somehow created by the user.
The GameObjectUtility.RemoveMonoBehavioursWithMissingScript-API is created to remove MonoBehaviours from GameObjects which are missing their script file. Since the GameObject has a MonoScript, not a MonoBehaviour, the API is not suitable for this type of action.
If we find out how these MonoScript references were added to the scene file, do file a new bug report, so that we can take a closer look at it with updated repro steps.
Resolution Note (6000.6.X):
Looking at the user project, the references in the scene file is of type "MonoScript". MonoScripts tends to be serialized into a scene file for:
- Special case MonoBehaviours, authored by Unity, with a native backing (e.g. Entity’s SubScene)
- Script references from Unity 4.x and older
We couldn't figure out how these references ended up in the scene file in the first place, but the assembly name points towards that these were somehow created by the user.
The GameObjectUtility.RemoveMonoBehavioursWithMissingScript-API is created to remove MonoBehaviours from GameObjects which are missing their script file. Since the GameObject has a MonoScript, not a MonoBehaviour, the API is not suitable for this type of action.
If we find out how these MonoScript references were added to the scene file, do file a new bug report, so that we can take a closer look at it with updated repro steps.