- Home /
Asset Server does not pick up on changes made to prefabs.
Hi there. I have a fallowing problem. I have a prefab in the project, talking about a prefab asset not a prefab instance. This prefab is just a Game Object with a script attached to it. I grab a reference to the script by using AssetDatabase.LoadAssetAtPath() and GetComponent<>() after I get the asset. That does return the appropriate reference. Now when I change values of some fields with scripting the Asset Server does not pick up on the changes at all. I found a work around by reverting the instance of the prefab in the scene and the applying it again. That forces the Asset Server to pick up on changes made. Now, the question is, am I missing a step with scripting that would refresh the changes in some way. I have tried both AssetDatabase.SaveAssets() and AssetDatabase.Refresh(ImportAssetOptions.Default). None of them do the job for me. If anyone has an answer to it, please get back to me.
I use AssetDatabase.Refresh(); all the time when I create new assets, and they are picked up. However, I do just save them to disk using the system and not unity.
Aye, it is a slightly different case. See if I edit my prefab in the project window, the Asset Server has no problem at all with picking up changes. I think that Unity must mark the asset in some way so the Asset Server knows that it has changed.
Answer by skalev · Dec 07, 2012 at 06:43 PM
You could try SetDirty() that will cause re-serialization on refresh.
http://docs.unity3d.com/Documentation/ScriptReference/EditorUtility.SetDirty.html
after that you might (not sure) have to call Refresh()
For the record, it's over a year later, but this worked for me. I used a Resources.LoadAll<>() and made changes to the returned components, but they weren't being picked up by the asset server until I added the SetDirty().