x


Determine if an external prefab exists within the project 's assets folder (not in scene)

I am using assets bundle to dynamically add prefabs to a scene and those prefabs can be cloned by the users. When a user clone a prefab, I need to determine if the prefab has been loaded. If not, then I will use the WWW class to load the asset bundles with the prefab.

Question is, how do I know that a prefab is loaded and ready to be clone?

more ▼

asked Apr 19 '10 at 05:41 PM

Extrakun gravatar image

Extrakun
1.3k 44 56 70

all prefabs will load in startup and you need to just download asset bundles to use.

Jun 12 '10 at 07:20 AM Ashkan_gc
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

If you know the name of the prefab you could try GameObject.Find. A return value of null would mean it is not loaded.

GameObject myPrefab = GameObject.Find("nameOfMyPrefab");
if( myPrefab == null )
{
  // Uh oh, my prefab has not loaded.
}
else
{
  // We found the prefab, therefore it loaded.
  // You may still have to check if its activated -
  //   I'm a bit unsure on this part!
}

Please post your results!

more ▼

answered May 29 '10 at 05:49 AM

Chris Masterton gravatar image

Chris Masterton
474 6 10 22

(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:

x5268
x1284
x394

asked: Apr 19 '10 at 05:41 PM

Seen: 1760 times

Last Updated: Apr 19 '10 at 05:41 PM