Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Extrakun · Apr 19, 2010 at 05:41 PM · prefabassetbundle

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?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ashkan_gc · Jun 12, 2010 at 07:20 AM 0
Share

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

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by LeMoine · Jan 28, 2014 at 01:27 AM

Ok, I found the solution here:

How to "Get" prefabs from project View by code

To check if a prefab is in the assets, use the Resources.Load("prefabName") method, like this:

 Object prefab;
 
 try{
     prefab = Resources.Load("prefabName");
 }            
 catch(UnityException e){            
     Debug.Log (e);
 }
 
 if(prefab == null){
     //doesn't exist
 }else{
     Debug.Log("Prefab exists");
 }

Pay attention that the prefab has to be in a folder named 'Resources'.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by Chris Masterton · May 29, 2010 at 05:49 AM

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!

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image LeMoine · Jan 28, 2014 at 12:57 AM 0
Share

didn't work for me, will post an answer if found

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

How to import the object from server to unity 2 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Storing a part of a complex asset in an asset bundle 1 Answer

cloned game object wont call script right... 2 Answers

Animation controller attached to prefab instance doesn't work 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges