Legacy Documentation: Version 5.0
Language: English
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Resources.LoadAll

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public static function LoadAll(path: string): Object[];
public static Object[] LoadAll(string path);
public static function LoadAll(path: string, systemTypeInstance: iOS.ADBannerView.Type): Object[];
public static Object[] LoadAll(string path, iOS.ADBannerView.Type systemTypeInstance);

Parameters

pathPathname of the target folder.
systemTypeInstanceType filter for objects returned.

Description

Loads all assets in a folder or file at path in a 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 any Resources folder inside the Assets folder of your project.

Note:
All asset names and paths in Unity use forward slashes, paths using backslashes will not work.

#pragma strict
// Loads all assets in the "Resources/Textures" folder
// Then picks a random one from the list.
// Note: Random.Range in this case returns [low,high)
// range, i.e. the high value is not included in the range.
function Start() {
	var go = GameObject.CreatePrimitive(PrimitiveType.Cube);
	var textures = Texture2D[]Resources.LoadAll("Textures");
	var texture = textures[Random.Range(0, textures.Length)];
	go.GetComponent.<Renderer>().material.mainTexture = texture;
}
// Loads all assets in the "Resources/Textures" folder
// Then picks a random one from the list.
// Note: Random.Range in this case returns [low,high)
// range, i.e. the high value is not included in the range.

using UnityEngine; using System.Collections;

public class ExampleClass : MonoBehaviour { void Start() { GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube); Texture2D[] textures = (Texture2D[]) Resources.LoadAll("Textures"); Texture2D texture = textures[Random.Range(0, textures.Length)]; go.GetComponent<Renderer>().material.mainTexture = texture; } }

public static function LoadAll(path: string): T[];
public static T[] LoadAll(string path);

Parameters

pathPathname of the target folder.

Description

Loads all assets in a folder or file at path in a 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 T will be returned. The path is relative to any Resources folder inside the Assets folder of your project.