x


Instantiate a GameObject from a Prefab without using an original to clone

Hi. I need to instantiate a game object from a prefab without the original prefab to clone. I want something that goes like:

Instantiate("prefabname");

This is supposed to go in runtime. Is this possible? I've heard of asset loading (i.e. using Resources.Load() or URLs) but I don't want to use any of those. Thanks in advance! :D

more ▼

asked Jul 30 '12 at 06:50 AM

brain56 gravatar image

brain56
29 7 12 16

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

1 answer: sort voted first

Without an existing prefab, or without a prefab in the scene? The latter is easily achieved by adding a GameObject variable to the script and dragging the prefab in there.

more ▼

answered Jul 30 '12 at 06:55 AM

Piflik gravatar image

Piflik
5.4k 15 26 44

Yeah, I realized that I had to make at least a pointer reference to the prefab. Thanks! :D

Jul 31 '12 at 06:25 AM brain56
(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:

x2087
x1674
x1257

asked: Jul 30 '12 at 06:50 AM

Seen: 300 times

Last Updated: Jul 31 '12 at 06:25 AM