Resources.LoadAll Manual     Reference     Scripting  
Scripting > Runtime Classes > Resources
Resources.LoadAll

static function LoadAll (path : string, type : Type) : Object[]

Description

Loads all assets in a folder or file at path in the Resources folder.

If path refers to a folder, all assets in the folder will be returned. If path refers to a file, only that asset will be returned. Only objects of type will be returned. The path is relative to the Resources folder. The Resources folder can be anywhere inside the Assets folder.

// Loads all assets in the "Resources/Textures" folder
// Then picks a random one from the list.
function Start ()
{
var go = new GameObject.CreatePrimitive(PrimitiveType.Cube);
var textures : Object[] = Resources.LoadAll("Textures", Texture2D);
var texture : Texture2D = textures[Random.Range(0, textures.Length)];
go.renderer.material.mainTexture = texture;
}

static function LoadAll (path : string) : Object[]

Description

Loads all assets in a folder or file at path in the Resources folder.

If path refers to a folder, all assets in the folder will be returned. If path refers to a file, only that asset will be returned. The path is relative to the Resources folder. The Resources folder can be anywhere inside the Assets folder.

// Loads all assets in the "Resources/Textures" folder
// Then picks a random one from the list.
function Start ()
{
var go = new GameObject.CreatePrimitive(PrimitiveType.Cube);
var textures : Object[] = Resources.LoadAll("Textures");
var texture : Texture2D = textures[Random.Range(0, textures.Length)];
go.renderer.material.mainTexture = texture;
}