0
\$\begingroup\$

I have a prefab A and i use it in scene A (as gameobject A). Then i to save that scene A as scene B and also renamed the gameobject A to gameobject B. Then inside unity (in project window ) , i duplicated the prefab asset A to prefab B.

Fyi, i'm using .blend (blender file) as the prefabs.

in scene B, i want the gameobject B which refers to prefab A , to switch its prefab's source to prefab B.

This way , i have 2 different scenes which has independent gameobjects which refer to unique prefab. So i can modify prefab A and will affect scene A but not scene B.

Ussually, i can drag the gameobject to project window and choose/create 'new original prefab' option, but this method can't be used, since i want both prefab as .blend file (so i can modify them directly using blender).

What i did so far, is to drag prefab B to scene B, which then i have to manually redo all the setting which has been done in scene A . I want to avoid this tedious process.

Does anyone have any idea ?

\$\endgroup\$
7
  • \$\begingroup\$ This does not sound like a good workflow, as you'll end up duplicating mesh data in your build. I would advise making two prefabs referencing a shared set of Blender meshes for anything they have in common. \$\endgroup\$
    – DMGregory
    Aug 10, 2020 at 17:56
  • \$\begingroup\$ You should look into "prefab variants": docs.unity3d.com/Manual/PrefabVariants.html \$\endgroup\$
    – Kevin
    Aug 10, 2020 at 18:01
  • \$\begingroup\$ @DMGregory sorry i don't get it. I won't build them both together so no duplicating when build. at the end, I will only use one of them. I just want to make alternatif scene, build scene A as A.apk and scene B as B.apk . I will compare and finally will only pick the one i like. My prefab is a house, where prefab A and B has different room composition. I will only use one of them when do final build. \$\endgroup\$
    – andio
    Aug 11, 2020 at 8:34
  • \$\begingroup\$ @Kevin yes but i can't use it. prefab variant will link to the same prefab A. So in my case, my prefab is a house where the prefab A and B will have different room layout. So it will be major different layout modification, which can't be handled by variant. But the objects are still the same (for example the same wall object : wall001 in scene A, will be moved to different position in scene B) so the setting from scene A should be able to applied to scene B (for example : the wall001 in scene B will be just the same object like scene A, so the previous component can be used ). \$\endgroup\$
    – andio
    Aug 11, 2020 at 8:43
  • \$\begingroup\$ Btw , when i drag gamobject from hierarchy to project, i will ask if i want create prefab as variant or original. If i select original, i expect it to recreate the same prefab file type as the master/original. So rather than create B.prefab, it should create B.blend ( because the original prefab is A.blend ). It should be simply duplicating to the .blend file. \$\endgroup\$
    – andio
    Aug 11, 2020 at 8:50

1 Answer 1

0
\$\begingroup\$

Found the solution. This is the dirty way. It only works if the sources are identical like in my case.

  1. Duplicate scene A to B.
  2. Duplicate prefab (A.blend to B.blend).
  3. In file explorer, open the meta files of these prefabs (blend files) using text editor (i use sublime text) and record the guid (object id) of each prefab.
  4. Open the scene B in text editor and do find/replace . Replace all the old guid of A.blend and replace it with guid of B.blend and save it.
  5. Open unity ( and reload the scene if it's open). Now in scene B , the gameobject is linked to the new B.blend. While in scene A, still link to A.blend. Now each scene has unique prefab while in scene B , i can still keep the gameobject setting from scene A.
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .