Hi, I’m trying to share work with a college and the scene file he sent me has lost all its links, prefabs turn red and need to be replaced. I have the prefab as well so instead of placing a hundred objects on the scene in the exact same places they were before is there a way to reconnect a prefab in a scene to the correct file in the project window?
You can’t reliably transfer raw scene files around, since they have other dependencies. Instead, have your colleague right-click the scene file and select Export Package… You should then be able to import that package to your project.
We did that.
Anyone know how to re-establish prefab links?
you can’t.
a prefab thats broken is broken.
you have to reimport the package that brought it in, revert on svn / vcs, …
Hi, I know this thread is old, but it could have a positive answer for someone who is having the same problem NOW.
I fixed the problem by copying the “prefabs that had turned red” and pasted them back. When you paste them back they are no longer prefabs but they are no longer red. I selected the parent, (if there is one) and create a new prefab of as many of 100 by making a prefab of the parent. Then deleted the red prefabs. It would be a pain to have to re-position so many clones. Good luck and hope this works for you too.
Ugh, thanks for this. I have been struggling with this absurdity and this is literally the only thread that actually answers the question.
Prefabs are kind of useless!
the script below helps replace duds based on their names if you’re lucky
be careful though… it literally deletes and replaces
using UnityEngine;
using System.Collections;
using UnityEditor;
public class ReattachPrefab : MonoBehaviour {
public bool pReplace=false;
public string pName;
public string pNewName;
public GameObject pPrefab;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnDrawGizmosSelected(){
if(pReplace){
pReplace=false;
//bool vFound=false;
for(int vNum=0;vNum<60;vNum++){
GameObject vObj=(GameObject)GameObject.Find(pName);
//vFound=false;
if(vObj!=null){
if(pPrefab!=null){
GameObject vNewObj=(GameObject)PrefabUtility.InstantiatePrefab(pPrefab);
vNewObj.transform.parent=vObj.transform.parent;
vNewObj.transform.position=vObj.transform.position;
vNewObj.transform.rotation=vObj.transform.rotation;
vNewObj.name=pNewName;
DestroyImmediate(vObj);
//vFound=true;
}
}
}
}
}
}
I’ve posted a utility in the Asset Store which has an Editor script that can fix broken prefabs.