Replace Linked Prefab on GameObject

I’m making a game where I have a lot of sawblades. I have, say, 300 of them in World 1 of my game placed around a load of different scenes.

alt text

I also placed a few hundred sawblades in World 2.

Then I decided in world 2, I want the Sawblades to be replaced by a functionally different icy spike balls that use a different script (and shatter when you hit them).

alt text

I want to replace all my sawblades in World 2 en masse, and have them linked to the spikeball prefab so that if I change anything else it’ll change all of them in every scene (because I iterate a lot and I frequently find myself having to go through 20 scenes changing all the objects because they aren’t linked to a prefab).

I don’t want to replace the Saw prefab because I want the saws to still exist, I just want to replace THESE SPECIFIC prefabs which are currently linked to saws, to be linked to iceballs instead.

My attempted solution was to replace them with this script, but this doesn’t work:

using UnityEngine;
using System.Collections;

[ExecuteInEditMode]
public class ReplacePrefab : MonoBehaviour {

    public GameObject newprefab;
    public bool go = false;

    void Start()
    {
        if (go && newprefab != null)
        {
            Instantiate(newprefab, transform.position, transform.rotation);
            DestroyImmediate(gameObject);
        }
    }
}

I mean, it replaced all the objects, but they just become instantiated clones, and they aren’t actually linked to the prefab. They’re linked to nothing.

I’m aware that if I hold Alt and drag the prefab over an object it will replace it, but it also replaces the position. I want them to remain in position.

Is there seriously no way to change which prefab an object is linked to?

Try PrefabUtility.

I think it’d look like this:

var newgo = PrefabUtility.Instantiate(newprefab);
newgo.transform.position = transform.position;
newgo.transform.rotation = transform.rotation;