x


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!

more ▼

asked Jul 26 '10 at 06:30 PM

DaveA gravatar image

DaveA
26.8k 153 171 257

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.

Sep 08 '10 at 09:51 AM SOIL

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.

Dec 21 '10 at 11:19 AM stijn
(comments are locked)
10|3000 characters needed characters left

4 answers: sort voted first

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.

more ▼

answered Oct 12 '10 at 12:50 AM

DaveA gravatar image

DaveA
26.8k 153 171 257

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)
10|3000 characters needed characters left

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?

more ▼

answered May 08 '12 at 08:44 PM

jwalker gravatar image

jwalker
31 1 1 2

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.

See Jonas answer here

May 12 '12 at 03:24 PM Bunny83
(comments are locked)
10|3000 characters needed characters left
more ▼

answered Sep 08 '10 at 09:53 AM

SOIL gravatar image

SOIL
89 24 25 33

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)
10|3000 characters needed characters left

I've posted a utility in the Asset Store which has an Editor script that can fix broken / missing prefabs.

https://www.assetstore.unity3d.com/#/content/8196

more ▼

answered May 01 at 03:12 PM

merlin981 gravatar image

merlin981
1

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3418
x1728
x1285
x841
x428

asked: Jul 26 '10 at 06:30 PM

Seen: 3145 times

Last Updated: May 01 at 03:12 PM