Replace Assets with Another Asset

Hey, I have a question for you guys… Is there a method or a script to replace an object with another object in the hierarchy? Example, in my level design, I have a series of cubes (unity cubes) that will serve as proxies for my level geometry (I like to block in my levels) that I modelled in Softimage (they are placed in the exact positions)…now I want to replace the selected object with the imported asset…

Any ideas? Thanks

You can change the mesh in the mesh filter I think.

Let me try that…because I have objects that are nicely placed in XSI… thanks a bunch man…

EDIT: Tried it… but I would have to keep the proxy on a 1,1,1 scale and there is no way to freeze that in Unity… :confused: Guess I will just place the asset by hand

hmm, what do you mean, which scale is getting messed up?

Use prefabs then just update the mesh/object whatever in the prefab with the new asset.

Script found on Unify Community (site is currently done, si I post the script here).
Put ReplaceSelection.cs in your Editor folder. The ReplaceSelection tool can be found in the GameObject menu.

801902–29480–$ReplaceSelection.cs (2.16 KB)

1 Like

When I replace the proxy with the real object, the scale is inherited, but the method is useless here since I want the entire model to be replaced…not just the mesh

Oh so I could create my prefab proxies and replace them accordingly? About to try that… :slight_smile:

EDIT: Works PERFECTLY! Although I have to move the replacement to its original place…:smile:

This is awesome…that was exactly what I was looking for :slight_smile: Thanks

EDIT: The script doesn’t take into account the rotation of the asset, but I will work around that… :slight_smile: