x


Active Prefabs

I am setting up a system where I click an object to enable another object, then I can click another object to disable both those objects...etc.

My problem is that the objects are prefabs. If I destroy it, I cannot access it to instantiate it again, and I cannot set prefab.active to simply disable it instead of destroying it.

The code is spread across multiple classes so I can't just paste it, but code should not be needed. I simply need to know how to add a reference to the object I want to enable and disable (it is a prefab I drag and drop on the script as a game object) without destroying it to disable it.

Hope that makes sense, I can try explaining another way if needed.

more ▼

asked Dec 01 '11 at 09:32 PM

SpectralEdge gravatar image

SpectralEdge
77 7 12 18

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

1 answer: sort voted first

You shouldn't be disabling the prefab itself. Try instantiating a 'prototype' object in Awake or something, somewhere far away from where the action occurs (9999,99999,9999 or something), and then using that like you would use a prefab. This way, you don't have to worry about modifying the prefab, and you can make all the changes you like before duplicating it.

more ▼

answered Dec 01 '11 at 09:43 PM

syclamoth gravatar image

syclamoth
15k 7 15 80

(comments are locked)
10|3000 characters needed characters left
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:

x1726
x1287
x785
x123

asked: Dec 01 '11 at 09:32 PM

Seen: 799 times

Last Updated: Dec 01 '11 at 09:43 PM