Find all instances of "Missing Script"
Asked Answered
I

6

0

Is there a method to list all instances of a 'Missing Script' after moving/deleting a file,

My experiment with junction and a common library of scripts seems to have failed, and left me with quite a mess to clean up!

Imelda answered 24/3 at 11:59 Comment(3)

Even though it's a question from a long time ago, a while ago I made a plugin for this, "Missing Script Hero": http://forum.unity3d.com/threads/released-missingscripthero-finding-missing-script-references-the-easy-way.273925/

Waldron

This is pretty insane I'm sorry to say. Imagine you have a huge scene and half your nodes have "missing scripts"..I mean comeone ! You might as well throw your game out the window.

Blackstock

I have made a tool to find out all missing references. Check it out here: https://www.assetstore.unity3d.com/#!/content/45693

Adulterous
L
0

See the solution to your problem here:

https://web.archive.org/web/20130514114424/http://wiki.unity3d.com/index.php/FindMissingScripts

Updated Link:

https://web.archive.org/web/20130514114424/http://wiki.unity3d.com/index.php/FindMissingScripts

Lowgrade answered 24/3 at 11:29 Comment(4)

Is there a way to determine the name of a missing script and replace it automatically (using an editor script)?

Kugler

AFAIK, that possibiliy got optimized away with 3.5. With <3.5, the referenced file would still be listed as a string in the binary asset (scene, material, prefab, ...) (which often helped us a lot if somebody deleted an asset at some point from the Asset Server, and you wanted to figure out which "Missing Script" was originally referenced. But since 3.5, they switched entirely to GUIDs, so assets are no longer referenced by path/name. There is AssetDatabase.GUIDToAssetPath(), but IIRC it returns null if the asset is no longer in the database. :-(

Immoralist

@Immoralist Would you mind demonstrating how to achieve this using GUIDs? I am not sure if you'll get this follow up comment. I certainly didn't get an e-mail notification of your comment...

Kugler

Broken link

Millennium
L
0

Not sure if I’m following. If you know the name of the script but don’t know which objects use it, you can create a script with that name and the following contents:

Note: this code is no C# but an obsolete (JS-like) Unity Script
function Start ()
{
    print("Script XYZ used by " + name);
}
Lowgrade answered 24/3 at 11:21 Comment(2)

Not it was more to find objects that have orphaned "Missing Script" entries.. IE: you have a bunch of objects that use script XYZ.cs, but then you delete that script file, but there are still entries on the objects that need to be 're-connected' EX: Renaming a file outside of the unity project window can break things. also cases where trying to Junction a set of standard scripts across multiple projects will cause the disconnection

Imelda

@AndreiMarian, did you see my last edit? Does this work for you?

October
D
0

I just read in another post (search “Mass Set Materials”) where the scripter used:

Undo.RegisterSceneUndo("Mass Set Materials");

This apparently allows you to Undo effect of your script.

Now, regarding you’re earlier problem, I too have had that problem, and don’t have a solution. I do think using this Undo method might help your experiments though. It is placed in the Start(), I recall.

Hope you find your answer - it will help a lot of us, I’m sure.

Drunk answered 24/3 at 11:25 Comment(0)
L
0

See the solution to your problem here:

https://web.archive.org/web/20130514114424/http://wiki.unity3d.com/index.php/FindMissingScripts

Updated Link:

https://web.archive.org/web/20130514114424/http://wiki.unity3d.com/index.php/FindMissingScripts

Lowgrade answered 24/3 at 11:29 Comment(4)

Is there a way to determine the name of a missing script and replace it automatically (using an editor script)?

Kugler

AFAIK, that possibiliy got optimized away with 3.5. With <3.5, the referenced file would still be listed as a string in the binary asset (scene, material, prefab, ...) (which often helped us a lot if somebody deleted an asset at some point from the Asset Server, and you wanted to figure out which "Missing Script" was originally referenced. But since 3.5, they switched entirely to GUIDs, so assets are no longer referenced by path/name. There is AssetDatabase.GUIDToAssetPath(), but IIRC it returns null if the asset is no longer in the database. :-(

Immoralist

@Immoralist Would you mind demonstrating how to achieve this using GUIDs? I am not sure if you'll get this follow up comment. I certainly didn't get an e-mail notification of your comment...

Kugler

Broken link

Millennium
C
0

This is an old problem. I would start with the Component Copier in the Asset Store (a real bargain!), and see how it uses Reflection. The idea would be to look at what fields are on a script to try to match them up with existing scripts and see what fits best. But I don’t think you can get at those fields once the script has gone missing (even though they still show up in the Inspector UI. Those are in the library/cache and we don’t have (official anyway) API’s to get at that. But then, you might look into the meta files and see what might be useful there.

Clifford answered 24/3 at 11:24 Comment(3)

Nothing, just the GUID of that particular asset. But if a script got deleted, the .meta file gets deleted along with it, and there is no way to recover the original path from a merely referenced GUID.

Immoralist

Yeah just checked that myself, was gonna delete that suggestion from my post. I had started working on an 'asset vault' system that would catalog scripts for just such occasions as I was tired of running into this problem. Instead I got into the habit of exporting my scenes as packages and archiving them.

Clifford

That vault sounds like a good idea. I seem to remember we got inconsistencies when transfering assets from project A to B via packages in 3.5, since the GUIDs of identical assets were different between projects...(might be their file locations were different, so they got different GUIDs, but so far I didn't investigate this further).

Immoralist
C
0

Find a referenced script gone missing due to delete/rename? Try this.

  1. Edit your asset/prefab file
  2. Search with the gameobject name to find an object with the field m_Name:
  3. Manually search down the immediately following entries to locate your component in the correct place in the list of components
  4. Copy the guid value
  5. In your bash or gitbash, run grep -r <paste guid here> Assets/ --include=*.meta

Will output the meta file of the referenced script. Voilá. If it outputs nothing, then I doubt that the script can be found cos the reference is with this guid only. In this case you need version control and to go back in history.

Cracking answered 11/11, 2021 at 17:3 Comment(0)
H
0

@Lowgrade , the links posted here are not working anymore, could you please enter valid links?
Thanks you, Huxi

Hanky answered 24/3 at 9:50 Comment(1)

Fixed them, take a look again.

Cake

© 2022 - 2024 — McMap. All rights reserved.