Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 rmccabe82 · Jan 19, 2015 at 07:53 AM · fbxruntimeanimation controllercompile

How to load a file after build

Hi,

I am building a new game where I have an fbx file of animation, associated with an animation controller. This moves a model in the game. No big deal there.

In the file system, if I replace the fbx file with a different animation (actually overwrite the fbx file with a file of the same name) and run the game, the new animation is picked up. This works through the Unity IDE.

However, when I build the game and take the same steps, only the animation that existed while the game was being built will ever play in the game.

Is there a way to dynamically load new animations into the compiled unity game?

Thanks in advance for any pointers!

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by CHPedersen · Jan 19, 2015 at 07:55 AM

Models, including their animations, are built into resource files when you build your stand-alone player. They are not actually loaded from separate files once the game is finally built.

To load files outside the normal Resources.Load pipeline post-build, you have to use AssetBundles. There is currently no other way to do so, short of writing your own content importer.

EDIT: Added more info on Asset bundles and how to load them.

AssetBundles are not created at runtime, they are created in the editor with an editor script. One would normally have to write this script oneself, but Unity made a sample editor script we can copy paste into our projects and use. It's available on this site, where you can also read in the docs about building AssetBundles:

http://docs.unity3d.com/Manual/BuildingAssetBundles.html

Copy paste that script into your project, then you can export your assets by rightclicking them and choosing Build AssetBundle From Selection. I only use the Track Dependencies version of it.

Afterwards, you now have an AssetBundle. This is a file that lives outside the normal Resources loading pipeline in Unity and can be loaded post build, which is what you require here. Loading them looks a little different from calling Resources.Load, but it's almost as simple. It can be done with few lines of code, I do it like this:

     AssetBundle assets = AssetBundle.CreateFromFile(Directory.GetCurrentDirectory() + "\\AssetBundles\\" + section.PartNumber + ".unity3d");
     assets.LoadAll();
     loadedObject = (GameObject)assets.mainAsset;

You have to supply your own path to AssetBundle.CreateFromFile, which is whereever you choose to store the .unity3d-file you originally exported using the editor script.

Hope that clears it up.

Comment
Add comment · Show 3 · 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 rmccabe82 · Jan 19, 2015 at 08:38 PM 0
Share

Im not sure I understand the answer. I've never setup asset bundles - can I build an asset bundle on the fly from code to allow me to import an FBX of my choosing?

avatar image CHPedersen · Jan 21, 2015 at 11:15 AM 0
Share

I have added more information to my answer now, please review and see if that helps. :)

avatar image dumbledad · Jul 25, 2017 at 09:17 AM 0
Share

https://docs.unity3d.com/$$anonymous$$anual/AssetBundles-Building.html is the current version of the URL you mention

avatar image
0

Answer by DaDonik · Jan 19, 2015 at 07:57 AM

ObjImporter

It's not for .fbx, but it circumvents the AssetBundles.

Comment
Add comment · Show 2 · 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 CHPedersen · Jan 19, 2015 at 07:59 AM 0
Share

Except that the obj format doesn't support animations...

avatar image DaDonik · Jan 19, 2015 at 08:09 AM 0
Share

Damn, didn't think of that...

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Mesh UV coords give weird result when FBX is imported at runtime 2 Answers

What is the best way to modify the Car Tutorial for more cars? 2 Answers

FBX Importer at runtime 2 Answers

How to add gameobject by fbx file at runtime ? 1 Answer

Manually Animating Bones then blending with existing animations or saving importing as fbx 3 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