x


Changing the prefab an object is associated with

I have a bunch of objects that I've populated my levels with, objects that are children of prefabs, and now have made alternate (similar but different in attributes such as shader color) prefabs that I'd like to replace selected placed objects with.

So... is there a way to change the prefab an object is a child of while still maintaining that objects local information like name and position?

more ▼

asked Jul 16 at 04:13 AM

Goody\'s gravatar image

Goody
479 21 30 45

(comments are locked)
10|3000 characters needed characters left
 moderation talk

2 answers:

If you want to change the prefab of a game object in a scene, you can simply drag the new prefab over the old object while holding the ALT key (that's on Mac - but I guess it would also be ALT on Windows).

This will keep the name and position of the object - but replace the "contents" of the objects.

This way, you could easily apply prefabs to placeholder objects - or change the prefab if you have multiple ones.

EDIT: When I say "drag the new prefab over the old object" I mean "drag the new prefab over the old object in the hierarchy pane". It seems that this doesn't work when dragging the objects over the scene view (which I, admittedly never even tried ;-) ).

more ▼

answered Jul 16 at 10:08 AM

Jashan\'s gravatar image

Jashan Chittesh
8.4k 20 32 102

Interesting. Drag over the object in the scene and it works. Not using alt gives the object the properties of the prefab without making it a prefab. One problem is that the objects always move after re-associating the prefab. Anyway around that?

Jul 18 at 09:54 PM Goody

Actually, when I use alt+drag, the objects don't move for me. When I don't use ALT, I instead create a new instance of the prefab (which would break the original prefab connection).

Jul 19 at 08:17 AM Jashan

I take it back, I was making new ones instead of changing old ones. :) Frustratingly, none of the standard key drag combinations (alt/shift/mac special button) do anything, dragged either on top of the object in the scene view or in the hierarchy. I have the free version of Unity. Do you have the paid?

Jul 19 at 11:51 PM Goody

I own Unity Pro but that sure doesn't make a difference in that area. Also, I'm using Unity 3 beta ... which may make more of a difference. Let me recheck with Unity 2.6.1 ... does work; with the ALT-key. For some odd reason it didn't work for me "in the beginning" but then, after trying all different keys, it did work.

What I do: Create 2 Prefabs, and 3 instances of those prefabs in a scene. Then, I ALT+drag/drop one prefab on all 3 instances. Works perfectly. Then, I ALT+drag/drop the other prefab on all 3 instances, again works like a charm. This is on Unity 2.6.1 (and with a real Mac kbd)

Jul 20 at 01:22 PM Jashan

Huh, sure don't work for me. I have 2.6.1 and a Mac Mini running osx 10.5.8. Tried unity iphone ver. 1.7 and it didn't work either. Suxs!

With 2.6.1 the new unwanted objects created by this method all seem to be placed at about -6000 on the Y. With 1.7 they are around -400.

My scene is a "top down" game with the cam rotated 90 on the X and the objects laying flat under it. I think I'm going to submit a bug for this. Thanks for your help!

Jul 20 at 09:23 PM Goody
(comments are locked)
10|3000 characters needed characters left
 moderation talk

I'm using 3.1, it doesn't seem to work.

more ▼

answered Jan 06 at 12:51 PM

Robin 1\'s gravatar image

Robin 1
1

(comments are locked)
10|3000 characters needed characters left
 moderation talk
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x720

Asked: Jul 16 at 04:13 AM

Seen: 1091 times

Last Updated: Jul 16 at 07:52 AM

powered by Qato - Enterprise Q&A