|
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!
(comments are locked)
|
|
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 MonoBehaviours and then an EditorWindow (created by Window>Fix Missing 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).
Nov 14 '12 at 05:34 PM
whydoidoit
(comments are locked)
|
|
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 (assuming you knew which one to add)?
May 12 '12 at 09:14 AM
JimmyJJeeter
@JimmyJJeeter: Unfortunately not. You can't remove this "dead" MonoBehaviour because the reference is null and you can't determine the old type via scripting.
May 12 '12 at 03:24 PM
Bunny83
(comments are locked)
|
|
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 determine the script. I've written some export/import scripts to save off stuff before the breakage, so I can repair it after.
Sep 08 '10 at 06:04 PM
DaveA
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
Sep 09 '10 at 05:43 AM
SOIL
(comments are locked)
|
|
I've posted a utility in the Asset Store which has an Editor script that can fix broken / missing prefabs.
(comments are locked)
|

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, instead I'll just bump this. It's quite anoying! What I did notice however, was that links to standard Assets (scripts, textures) are preserved.