• 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
1
Question by bertinerd · Apr 27, 2012 at 03:10 PM · assetbundleruntimedynamic loadingcollada

Dynamic import of collada asset

Hi everybody.

I absolutely need to import a collada (.dae) asset dynamically through a script. Dynamically because I'm building an application which models a mesh accordingly to some user input, so I cannot recompile in Unity.

I tried to use AssetBundles but I'm quite a newbie in Unity, maybe I'm missing some important point.

Here my few lines of code, the script is attached to a empty game object in unity. Basically I want to import the collada asset in the path and put the object "monkey" inside the scene. :-|

WWW urlExternalAsset = new WWW("file://D:/Unity/monkey.dae"); GameObject go; void Start () { AssetBundle bundle = urlExternalAsset.assetBundle; go = bundle.Load("monkey", typeof(GameObject)) as GameObject; Instantiate(go); }

Thank you for your help. I'm doing a project with my university and this part is fundametal for me;)

Luca

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
1

Answer by ricardo_arango · Apr 27, 2012 at 05:17 PM

To use AssetBundles you need to:

1 Build an AssetBundle that includes the Monkey Asset. Note that this is not the collada file, but the Asset that you see in the Project folder. The instructions to do that you can find in these places:

http://unity3d.com/support/documentation/Manual/AssetBundles http://unity3d.com/support/documentation/ScriptReference/BuildPipeline.BuildAssetBundle.html

*Note: The file extension for the AssetBundle is not important.

2 Put that AssetBundle file in a location where you will load it from:

D:/Unity/monkey.assetbundle

3 Download the AssetBundle using the WWW class:

 IEnumerator Start (){
    WWW urlExternalAsset = new WWW("file://D:/Unity/monkey.assetbundle");
    yield return www;
 
    // 4. Retrieve the AssetBundle from the WWW object:
    AssetBundle bundle = urlExternalAsset.assetBundle;
 
    // 5. Load the Mokey GameObject from the AssetBundle:
    GameObject go = bundle.Load("monkey", typeof(GameObject)) as GameObject;
 
    // 6. Instantiate the GameObject:
    Instantiate(go);
 }

Enjoy!

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 Eldamir88 · Nov 20, 2019 at 03:04 PM 0
Share

This does not address the "dynamic" part. The app is already running, and doesn't have access to the Unity Editor. It can pickup the DAE file from disk, but how does it turn into a GameObject? I have read in another place that the DAE parser is part of the Editor, not the app runtime, so the functionality that turns a DAE file into an asset is not accessible outside of the Unity Editor. But then how can it be done?

Can the unity editor be controlled through scripts to sit in the background and build AssetBundles on request?

avatar image
0

Answer by bertinerd · May 03, 2012 at 10:28 PM

Ok. I think that what I've done is just what you described in point 3.

I can't understand the meaning of what is described in the first 2 points...what does build the asset bundle mean? Considering that I'm creating the .dae file runtime I need to load it also runtime in a previously built file. I can't launch the unity editor, I can just use scripts.

I will try to summarize of does my pipeline work

  • I have a C# program continuosly getting infos from a Kinect

  • On the other side, I have a unity .exe (which I already created), that shows a 3d avatar.

  • After an acquisition phase I stop getting data from the Kinect and I run the previously built Unity .exe, which should use the data acquired runtime to build the 3d world. I did it successfully with textures...now I want to apply the same procedure also to meshes. --> That's why I need to import collada .dae dynamically.

Do you think this is possible with AssetBundles? What could use if not?

Thank you so much.

Luca

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



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

How to modify "resources.assets" (or alternative?) 2 Answers

Asset Bundles and dynamic loading 0 Answers

Export objects to a .3DS file at runtime 1 Answer

Replace texture without touching materials? 1 Answer

Load Animator Runtime. 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges