Version: 5.3 (switch to 5.4b)
IdiomaEnglish
  • C#
  • JS

Idioma de script

Selecciona tu lenguaje de programación favorito. Todos los fragmentos de código serán mostrados en este lenguaje.

Resources.LoadAll

Sugiere un cambio

¡Éxito!

Gracias por ayudarnos a mejorar la calidad de la documentación de Unity. A pesar de que no podemos aceptar todas las sugerencias, leemos cada cambio propuesto por nuestros usuarios y actualizaremos los que sean aplicables.

Cerrar

No se puedo enviar

Por alguna razón su cambio sugerido no pudo ser enviado. Por favor <a>intente nuevamente</a> en unos minutos. Gracias por tomarse un tiempo para ayudarnos a mejorar la calidad de la documentación de Unity.

Cerrar

Cancelar

Cambiar al Manual
public static function LoadAll(path: string): Object[];
public static Object[] LoadAll(string path);
public static function LoadAll(path: string, systemTypeInstance: Type): Object[];
public static Object[] LoadAll(string path, Type systemTypeInstance);

Parámetros

path Pathname of the target folder. When using the empty string (i.e., ""), the function will load the entire contents of the Resources folder.
systemTypeInstance Type filter for objects returned.

Descripción

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.


        
// 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);

Parámetros

path Pathname of the target folder. When using the empty string (i.e., ""), the function will load the entire contents of the Resources folder.

Descripción

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.