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.FindObjectsOfTypeAll

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 FindObjectsOfTypeAll(type: Type): Object[];
public static Object[] FindObjectsOfTypeAll(Type type);

Parámetros

type Type of the class to match while searching.

Valor de retorno

Object[] An array of objects whose class is type or is derived from type.

Descripción

Devuelve una lista de todos los objetos de tipo type.

This function can return any type of Unity object that is loaded, including game objects, prefabs, materials, meshes, textures, etc. It will also list internal stuff, therefore please be extra careful the way you handle the returned objects. Contrary to Object.FindObjectsOfType this function will also list disabled objects.

Por favor, tenga en cuenta que esta función es muy lenta y no se recomienda usar en todos los frames.


        
using UnityEngine;
using System.Collections;

public class ExampleScript : MonoBehaviour { // This script displays the number of allocated Unity objects by type. // This is useful for finding leaks. Knowing the type of object // (mesh, texture, sound clip, game object) that is getting leaked is // the first step. You could then print the names of all leaked assets of that type.

void Start() { print("All " + Resources.FindObjectsOfTypeAll(typeof(UnityEngine.Object)).Length); print("Textures " + Resources.FindObjectsOfTypeAll(typeof(Texture)).Length); print("AudioClips " + Resources.FindObjectsOfTypeAll(typeof(AudioClip)).Length); print("Meshes " + Resources.FindObjectsOfTypeAll(typeof(Mesh)).Length); print("Materials " + Resources.FindObjectsOfTypeAll(typeof(Material)).Length); print("GameObjects " + Resources.FindObjectsOfTypeAll(typeof(GameObject)).Length); print("Components " + Resources.FindObjectsOfTypeAll(typeof(Component)).Length); } }

        
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;

public class ExampleScript : MonoBehaviour { // This script finds all the objects in scene, excluding prefabs:

List<GameObject> GetAllObjectsInScene() { List<GameObject> objectsInScene = new List<GameObject>();

foreach (GameObject go in Resources.FindObjectsOfTypeAll(typeof(GameObject)) as GameObject[]) { if (go.hideFlags == HideFlags.NotEditable || go.hideFlags == HideFlags.HideAndDontSave) continue;

if (!EditorUtility.IsPersistent(go.transform.root.gameObject)) continue;

objectsInScene.Add(go); }

return objectsInScene; } }

public static function FindObjectsOfTypeAll(): T[];
public static T[] FindObjectsOfTypeAll();

Descripción

Devuelve una lista de todos los objetos de tipo T.

This function can return any type of Unity object that is loaded, including game objects, prefabs, materials, meshes, textures, etc. It will also list internal stuff, therefore please be extra careful the way you handle the returned objects. Contrary to Object.FindObjectsOfType this function will also list disabled objects.

Por favor, tenga en cuenta que esta función es muy lenta y no se recomienda usar en todos los frames.


        
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;

public class ExampleScript : MonoBehaviour { // This script displays the number of allocated Unity objects by type. // This is useful for finding leaks. Knowing the type of object // (mesh, texture, sound clip, game object) that is getting leaked is // the first step. You could then print the names of all leaked assets of that type.

void Start() { print("All " + Resources.FindObjectsOfTypeAll<UnityEngine.Object> ().Length); print("Textures " + Resources.FindObjectsOfTypeAll<Texture> ().Length); print("AudioClips " + Resources.FindObjectsOfTypeAll<AudioClip> ().Length); print("Meshes " + Resources.FindObjectsOfTypeAll<Mesh> ().Length); print("Materials " + Resources.FindObjectsOfTypeAll<Material> ().Length); print("GameObjects " + Resources.FindObjectsOfTypeAll<GameObject> ().Length); print("Components " + Resources.FindObjectsOfTypeAll<Component> ().Length); } }
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;

public class ExampleScript : MonoBehaviour { // This script finds all the objects in scene, excluding prefabs:

List<GameObject> GetAllObjectsInScene() { List<GameObject> objectsInScene = new List<GameObject>();

foreach (GameObject go in Resources.FindObjectsOfTypeAll(typeof(GameObject)) as GameObject[]) { if (go.hideFlags == HideFlags.NotEditable || go.hideFlags == HideFlags.HideAndDontSave) continue;

if (!EditorUtility.IsPersistent(go.transform.root.gameObject)) continue;

objectsInScene.Add(go); }

return objectsInScene; } }
no example available in C#