Missing Script Hunter
Finds GameObjects in project scenes and prefabs whose MonoBehaviour slots are missing (script deleted, GUID moved, or assembly dropped).
Editor-only. Unity 2021.3+. Lives in Anvil.Editor (includePlatforms: Editor). No extra packages.
Editor window
ArTchie / Anvil / Missing Script Hunter
| Control | What it does |
|---|---|
| Include / Exclude | Comma-separated assetPath substrings. Empty include = all. Exclude wins. |
| Scan | Walks every scene and prefab under Assets/ (skips Packages/, Library/, and model prefabs). |
| Copy JSON | Puts the report JSON on the clipboard. |
| Write report | Writes <project>/AnvilReports/missing-scripts.json (creates the folder if needed). |
| Strip missing (Undo) | Removes missing MonoBehaviours on the last scan's assets via GameObjectUtility.RemoveMonoBehavioursWithMissingScript and Undo.RegisterCompleteObjectUndo. Prefabs are saved. Then those assets are rescanned. |
| Filter | Hides result rows unless guid, asset path, or object path contains the substring. |
| Ping / Select | Loads the scene (OpenScene) or prefab contents (PrefabStageUtility.OpenPrefab) and pings / selects the GameObject. |
Each row is: assetPath, kind (scene or prefab), GameObject hierarchy path, component index, and the missing script GUID when it is still in the YAML.
Batchmode (CI)
Unity -batchmode -nographics -quit -projectPath <proj> -executeMethod Anvil.MissingScriptHunter.RunBatch -anvil-out <file.json> -anvil-fail
| Arg | Meaning |
|---|---|
-anvil-out <file.json> |
Output path. Default: <project>/AnvilReports/missing-scripts.json |
-anvil-fail |
Exit code 1 if any missing scripts were found; otherwise 0 |
-anvil-strip |
After the scan, strip missing scripts on those assets, rescan them, and set "stripped": true. Without this flag, batch never strips. |
-anvil-include <substr> |
Repeatable. Keep only assets whose assetPath contains at least one include. |
-anvil-exclude <substr> |
Repeatable. Drop assets whose assetPath contains any exclude. |
RunBatch only calls EditorApplication.Exit when Application.isBatchMode is true. It logs count=, assetsScanned=, modelsSkipped=, stripped=, and the output path.
Also accepts -anvil-out=file.json and -anvil-include=substr / -anvil-exclude=substr.
JSON
{
"tool": "MissingScriptHunter",
"generatedUtc": "2026-08-18T02:00:00Z",
"count": 1,
"assetsScanned": 12,
"modelsSkipped": 3,
"stripped": false,
"errors": [
{
"assetPath": "Assets/Scenes/Broken.unity",
"message": "Could not open scene."
}
],
"byAsset": [
{
"assetPath": "Assets/Scenes/Main.unity",
"count": 1
}
],
"items": [
{
"assetPath": "Assets/Scenes/Main.unity",
"kind": "scene",
"objectPath": "Player/Weapon",
"componentIndex": 3,
"guid": "deadbeefdeadbeefdeadbeefdeadbeef"
}
]
}
guid is "" when the YAML has no m_Script guid (binary assets, stripped prefab instances with no source, or a parse miss).
errors is filled when a scene or prefab fails to open; the rest of the scan continues. byAsset is a per-assetPath count of items. modelsSkipped counts FBX/OBJ/Blend/DAE and PrefabAssetType.Model prefabs that were not scanned.
Notes
- Prefabs are loaded with
PrefabUtility.LoadPrefabContents/UnloadPrefabContents. - Scenes: additive open+close in the Editor window (restores your previous setup);
OpenSceneMode.Singlein batch. - Prefab instances in scenes are scanned live; GUIDs may be read from the source prefab YAML.
- Binary-serialized scenes/prefabs still list missing scripts; GUID may be empty.
- Model prefabs (
.fbx,.obj,.blend,.dae, orPrefabAssetType.Model) are skipped. - Empty projects and a missing
AnvilReportsfolder are fine. - Window strip registers Undo on loaded objects. Prefab assets are saved immediately (
SaveAsPrefabAsset). Scenes opened only to strip are saved before close; scenes already loaded are marked dirty and left for you to save. Batch strip always saves. - Does not touch runtime player code. Whole file is
#if UNITY_EDITOR.
Source in the box: Assets/ArTchie Studios/ArTchie-Suite/com.artchie.anvil/Documentation/MissingScriptHunter.md