Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
0
Question by SuperHxNJU · Aug 11, 2014 at 10:58 AM · prefabassetbundle

how can I export a prefab modified from fbx model?

There is my operation:

  1. drag fbx model to hierarchy.

  2. modify game object structure.

  3. create prefab of the game object.

  4. export prefab to Asset Bundle.

  5. load Asset Bundle through WWW.

When I load the game object from AssetBundle, the structure is same as original game object that created by dragging fbx model to hierarchy. And I found if I substitute the material and delete origin material in step (2),the game object load in step 5 change to pink.

Is anyone know how to fix it or give another method to fulfil the need of exporting the prefab modified from fbx model.Thanks!

Comment
Add comment · Show 3
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 Graham-Dunnett ♦♦ · Aug 11, 2014 at 10:59 AM 0
Share

You question is hard to read. What is your step (2) and step (4) actually doing? Pink means a shader cannot be found.

avatar image Subhajit-Nath · Aug 11, 2014 at 11:10 AM 0
Share

Anytime you delete a material that is used by some object, that object will turn pink to notify you of a missing material.

avatar image SuperHxNJU · Aug 12, 2014 at 08:10 AM 0
Share

@Subhajit Nath ,I substitute material to another.And it works before step 3.But in setp5,it turn to pink.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by VatelsRevenge · Aug 29, 2014 at 12:46 AM

I've been running into similar issues. I fixed mine by making sure my fbx has a different name than the prefab I generate. It's almost as if sharing the same filename causes unity get confused as to what it should do.

From what I can tell, if the fbx and the prefab share the same name (extension doesn't matter) then when I load the prefab from the asset bundle it'll try to load either the fbx or the prefab. And of course, if it loads the fbx, it will be wrong and missing dependencies because I changed them on the prefab.

Makes me wonder if adding a prefab to an asset bundle causes a bunch of things to be added (materials, textures, fbxs) and everything is defined in the asset bundle by file names without extension or directory. Which would be terrible.

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 SuperHxNJU · Aug 29, 2014 at 01:12 AM 0
Share

Thank you for your answer.It's helpful.

avatar image
0

Answer by miron83 · May 13 at 09:49 AM

It's not bad idea to name model and prefab the same, however it's true that usng just name without an extension, unity will pick fbx over prefab. Therefore the best and safe practice is to check all attached elments in asset and look for a prefab:

 public GameObject LoadModelFromFile(string _filePath, string _modelSlug)
 {
 
     AssetBundle _Bundle;
     _Bundle = AssetBundle.LoadFromFile(_filePath);
     
     bool _prefab = false;
     foreach (string _s in _Bundle.GetAllAssetNames()){            
         _prefab = (_s.LastIndexOf(_modelSlug + ".prefab") > -1) ?true:false;
     }
 
     GameObject _Obj = _Bundle.LoadAsset(_modelSlug + ((_prefab)?".prefab":"")) as GameObject;
     _Bundle.Unload(false);
 
     return _Obj;
 }

Safe because you can also have assets without a prefab and thanks to checking the asset boundle first you're sure that it wont run into an error.

Just remember that when you making a prefab from fbx, before exporting them to asset boundle, make sure to choose a "prefab variant" not "original prefab". Otherwie your prefab will not have meshes or other fbx attributes attached to it. Don't forget to change the name after doing so, as editor will add " Variant" to the name...

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

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Add Asset Bundle Name to a prefab in "Editor Code" 1 Answer

why does the error "Deleting persistent object without writing it first" occurs ? 4 Answers

How to build asset bundle without dependencies? 1 Answer

Nested Prefabs in Asset Bundle 1 Answer

Problems importing an asset bundle 1 Answer


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