Calling from library at runtime

Is there anyway i can call an asset straight from my library at runtime?

I wanted to be able to call textures and sounds this way, without having to drag drop 20 assets into the script

Can it be done?

Thanks in advance

Use Resources.Load.

–Eric

yes and you should put those assets in folders called resources

it’s unity’s biggest problem
also you can load resources by
www (“file://filepath”) but just some audio and JPEG and PNG files can be used in this manner.
you can use asset bundles from your hard disk like this with file:// paths

this is one of unity’s limitations and i really will become more than happy if solved but hey guys i did not buy it yet and just used the trial

Hello,

I’m trying to dynamically load an audio clip based on its directory location with javascript:

var musicTrack : AudioClip;

function Start ()
{
var musicFile = “Assets/music/songTitle/music.ogg”;
musicTrack = Resources.LoadAssetAtPath(musicFile, AudioClip);
musicTrack.Play();
}

However I am getting the error:

NullReferenceException: Object reference not set to an instance of an object
LoadTracks.Start ()

Can this be done?

Thank you, maximum respect,
GuitarGuy91403

As said above, the resource you want to load must be in a folder called Resources

Hi all,

I’ve been using the FMOD/Unity plugin and so far so good! Really cool.
It loads files at runtime and DSP, multi-channel, getSpectrum all work -

However, I can’t get the following to work:

C++ code, provided in the FMOD examples:

system->createSound(0, FMOD_2D | FMOD_SOFTWARE | FMOD_LOOP_NORMAL | FMOD_OPENUSER, &exinfo, &sound);

The above works fine, when I build run from Mac OS X 10.5.8 XCode.

However, when I convert the above C++ to C# to be used with Unity, here is the C# code:

system.createSound( 0 , FMOD.MODE._2D | FMOD.MODE.SOFTWARE | FMOD.MODE.OPENUSER  , ref exinfo, ref sound);

I get errors:

Argument 1: Cannot convert type `int' to `string'

What is the proper way to create the sound?

Thank you, maximum respect, GuitarGuy91403