- Home /
Getting properties on 'missing' things in Editor Scripts?
Often when I move assets (even as Packages) between computers, I have missing scripts, missing materials, missing textures. In the case of scripts, it says 'missing mono script' BUT it lists public variables that those scripts had before it went missing.
I'd like to write an Editor script that will a) find missing components like that, and b) try to match them up with the asset (say, script by comparing public variables), and c) re-attach the assets.
Is any of that possible? I found a script that will detect missing scripts, but how would I get those public variables that it seems to remember?
Is there any way to 'patch up' 'missing' assets?
For example, Prefabs seem to get detached. There is no way to reattach them (that I know of), except to re-add the Prefab, fix it's name if needed, and reset transform etc. as needed. I want to script that.
Help please!
I have the same problem too. Specially by switching from UNITY PRO to UNITY IPHONE i always lose many linkages! i found a "find missing script" > look at the answer. But i can't help you with the problem on missing textures, materials.
I was gonna post the exact same question, ins$$anonymous$$d I'll just bump this. It's quite anoying! What I did notice however, was that links to standard Assets (scripts, textures) are preserved.
Answer by DaveA · Oct 12, 2010 at 12:50 AM
After much searching, coding, and frustration, I've concluded that it is not possible. The best course of action is to use Reflection to save off important settings to a file, then import that file to recreate the objects as needed. Not easy.
Dave - I figured this out - it is possible to fix up scripts at least. I read your advice and fiddled and fiddled and came up with a way of doing it. A bodge, but a working one. Package is here.
It works by having an Inspector that will inspect $$anonymous$$onoBehaviours and then an EditorWindow (created by Window>Fix $$anonymous$$issing Scripts) that finds all missing and then rapidly makes them be the focussed object in the inspector - waits for the Inspector to identify if it can fix it (using the rules about an existing script having all of the same fields).
Answer by SOIL · Sep 08, 2010 at 09:53 AM
Thanks I found this a long time ago (as I said in my question). I need to know which script went missing, or at least the parameter list, so I might be able to deter$$anonymous$$e the script. I've written some export/import scripts to save off stuff before the breakage, so I can repair it after.
oh cool - sounds great! i was not sure u allready found the answer, so i thought i give you that link. but may i suggest you to mark this question as answered or delete it? anyhow - so we can keep this site clean. i do it too. greetings
Broken link, now it is at: http://wiki.unity3d.com/index.php?title=Find$$anonymous$$issingScripts
Answer by jwalker · May 08, 2012 at 08:44 PM
I want to try and solve the same problem. Did anyone ever find a way to do this? We often move scripts from being a loose .cs file into a pre-built assembly, or from one pre-built assembly to another. This always breaks the script linkages everywhere and takes a lot of time to manually fix everything. The "Find Missing Scripts" technique helps a bit, but it would be very easy to automatically fix all the scripts, if only there was a way to set the script that the component points to. Currently, the Editor API only provides a way to add new components. I cannot find any way to modify the script that an existing component points to. I know it's possible since the Editor itself allows you to change the script that a component points to, so maybe this is something easy to support in a future version of Unity?
If you cant change the script, could you remove the old and add a new (assu$$anonymous$$g you knew which one to add)?
@JimmyJJeeter: Unfortunately not. You can't remove this "dead" $$anonymous$$onoBehaviour because the reference is null and you can't deter$$anonymous$$e the old type via scripting.
Answer by merlin981 · May 01, 2013 at 03:12 PM
I've posted a utility in the Asset Store which has an Editor script that can fix broken / missing prefabs.