Dynamic Asset loading?

Is is possible to load assets (models/textures/sounds) on runtime?

Been peeking the forums and saw some old posts where it wasn't but then i saw Resource.load, so i'm confused.

Yes, this is possible - check out the AssetBundle class (http://unity3d.com/support/documentation/ScriptReference/AssetBundle.html). This class is for loaded via the web specifically, I assume this is what you had in mind? Resource.Load() is used for loading assets by path name in the resources folder.

AssetBundle has been introduced fairly recently, hence the old forum posts where this was not possible.

hi, actually when using the resources folder the asset is encapsulated within the unity file (as part of it) this means that it is not fully dynamically loaded thus if you want to load a file that is not in the resources folder then you need to rebuild your application after adding it to the resources folder, resources folder is always attached and deployed with the unity file but if you want really dynamic loading of assets you need to use the WWW Class either you pick asset bundles for your content streaming (Pro) or you might use its functions to load Textures, Audio, Video and to load models you mights take a look at Mesh Serializer2 at unifycommunity.com.

resources folder will always combine your files and assets within the unity file thus you can't load them unless they are built within the unity file, other content deployed somewhere else can't be loaded through Resources.Load() function.

yes it is very simple. All you resources got into the directory "resources". Then you can use resources.load to load them into you scene at runtime.

I just recently ran into the same issue and wanted to post the following code, it is basically an extenstion of what xeophin posted and I can confirm that it is working.

In this example, I have a GameObject with an AudioSource component attached and a script with a function called PlayClip. I pass the audio clips name that then loads clip from the Resources fold.

public void PlayClip(string clipName){
     AudioSource source = gameObject.GetComponent<AudioSource>();
     source.rolloffFactor = 0;
     AudioClip clip = Resources.Load(clipName)as AudioClip;
     source.clip = clip;

note - I am making the AudioSource rolloffFactor 0 so that it can be heard everywhere without, well, fallOff. That one got me for a few minutes.

Sorry just seconds after I posted the comment, I got it to work, using the following code (assuming the same example you used):

AudioClip clipObj = Resources.Load("GoodAfternoon") as AudioClip;

That should work.

Probably this help page didn’t exist when the question was asked over 2 years ago, but nevertheless it is today a direct answer to it. I’ll quote a relevant part:

In Unity Pro/iOS Advanced/Android Advanced, you can choose between two options for accomplishing these tasks: Asset Bundles, and Resource Folders. Non-Pro/Advanced license holders can use Resource Folders only.