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 /
  • Help Room /
avatar image
1
Question by ensomniac · Oct 04, 2016 at 09:55 PM · assetbundleresourcesresource.load

How do you import non-hierarcy assets from an Asset Bundle?

I've lost a full day here and looking for some help.

Our game has a large number of fbx files that contain animation.

I am successfully creating asset bundles of these FBX files. At runtime, I can download the neatly packaged Asset Bundle from our server.

I am extracting the Bundle like this:

 AssetBundle asset = asset_download.assetBundle;

I have tried:

 asset.LoadAllAssets()
 asset.LoadAsset(asset_path)

But I am lost as to what is being extracted and to where.

For convenience sake, all of our FBX files are in /Resources/anim/asset_name/...

Although that seems to not be correct if we're using asset bundles.

I had expected that on asset.LoadAllAssets(), those FBX files would simply appear back in their respective /Resources/ path and become accessible to anything that needs them.

It seems as though the only way I can do anything with the assets that have been bundled is:

 Instantiate(asset.LoadAsset(asset_name));

Which puts a clone of the packaged object in the current scene and not at all what I need.

Any idea how to put resources back into some sort of persistent "project" location so that those animation files can be used as if they had been packaged with the build?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Cynikal · Oct 04, 2016 at 10:47 PM

I see you put:

asset.LoadAsset(asset_path). This is not correct.

It's asset.LoadAsset(asset_NAME) (like you have mentioned below in your instantiate).

According to the Wiki, you can do: asset.LoadAsset(asset_name, TYPE); Where type is, you could put Animation. I am assuming (since i've never used Asset Bundles for any of my actual projects, just did it for testing) that you can put it into a List myAnis = asset.LoadAsset(asset_name, Animation); or something similar.

Comment
Add comment · Show 6 · 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 ensomniac · Oct 05, 2016 at 02:06 PM 0
Share

Unfortunately, this doesn't work either. I'm baffled by this - what happens to the asset on bundle.LoadAsset(asset_name)? Does it have to go into the current scene?

Whether I load the asset using the full path: "assets/content/anim/yari/20161002182113.fbx" or the name "20161002182113" nothing happens. Unless I wrap it in Instantiate(), which loads it into the current scene, which isn't what I want.

avatar image Cynikal ♦ · Oct 05, 2016 at 03:32 PM 0
Share

Can you send the bundle you're trying to use?

avatar image ensomniac Cynikal ♦ · Oct 05, 2016 at 03:35 PM 0
Share

Sure - you can download it from http://oapi.co/kurotama/local_storage/bundles/20161002182113

It contains a single FBX file that only contains animation: assets/content/anim/yari/20161002182113.fbx

$$anonymous$$y goal is to take this animation and apply it to an Animator Controller on an existing model after loading the asset bundle. But Once loading the asset, I have no idea where it lives or how to access it.

avatar image Cynikal ♦ · Oct 05, 2016 at 05:27 PM 0
Share
 using System;
 using UnityEngine;
 using System.Collections;
 using UnityEditor;
 using Object = UnityEngine.Object;
 
 public class TestForUnityAnswers : $$anonymous$$onoBehaviour
 {
 
     // Use this for initialization
     void Start()
     {
         StartCoroutine(DownloadAsset<AnimationClip>("20161002182113", "http://oapi.co/kurotama/local_storage/bundles/20161002182113", 1));
     }
 
     public Object Obj;
     public IEnumerator DownloadAsset<T>(string asset, string url, int version) where T : Object
     {
         Obj = null;
 
         while (!Caching.ready)
             yield return null;
 
         using (WWW www = WWW.LoadFromCacheOrDownload(url, version))
         {
             yield return www;
             if (www.error != null) throw new Exception("WWW download: "+ www.error);
             AssetBundle assetBundle = www.assetBundle;
             Obj = assetBundle.LoadAsset(asset, typeof(T));
             assetBundle.Unload(false);
         }
 
         //GameObject test = GameObject.Find("TESTFORUNITY");
 
         //obj = contains your animations.
 
     }
 }
 
avatar image ensomniac Cynikal ♦ · Oct 05, 2016 at 08:03 PM 0
Share

I really appreciate you taking the time to put this together. It clarifies a bit of my confusion, but I'm still largely confused.

Your code explicitly sets the objects on unpacking. If there are dependencies, say an Animation Controller that references FBX files, I assume the FBX files need to be explicitly unpacked first. Do you know if that's the case?

Further, this works fine for a simple example like the one I mention here, but I'm concerned about how this scales. If I were to have a bundle with 20 or so FBX files and 30 controllers and other components, do they always need to be unpacked with this degree of care at runtime?

Is there no way to unpack the bundle once and allow those elements to simply exist? Or does a cached bundle always need to be decompressed at runtime and loaded?

Again, you've been super helpful and I understand if you don't have all of the answers - just thrilled to have someone who can provide some clarity!

avatar image Cynikal ♦ · Oct 05, 2016 at 05:29 PM 0
Share

So, you'll want to do manipulate the "Obj" file, which contains your animations... then add them to wherever.

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

78 People are following this question.

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

Related Questions

load .unity3d assetbundle from resource folder 0 Answers

DLC - Help downloading assets and saving locally 1 Answer

Asset Bundle vs Resources vs ?? 1 Answer

What use instead of Resources folder? 3 Answers

how to load texture from C:\ Folder at Runtime build 2 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