Buscamos por el mundo online para tenerte la respuesta para tu inquietud, si tienes preguntas puedes dejar tu pregunta y te respondemos con gusto.
Ejemplo 1: cómo encontrar objetos de juego en la unidad
using UnityEngine;
using System.Collections;// This returns the GameObject named Hand in one of the Scenes.publicclassExampleClass: MonoBehaviour
public GameObject hand;voidExample()// This returns the GameObject named Hand.
hand = GameObject.Find("Hand");// This returns the GameObject named Hand.// Hand must not have a parent in the Hierarchy view.
hand = GameObject.Find("/Hand");// This returns the GameObject named Hand,// which is a child of Arm > Monster.// Monster must not have a parent in the Hierarchy view.
hand = GameObject.Find("/Monster/Arm/Hand");// This returns the GameObject named Hand,// which is a child of Arm > Monster.
hand = GameObject.Find("Monster/Arm/Hand");
Ejemplo 2: obtener gameobject por nombre
using UnityEngine;
using System.Collections;// This returns the GameObject named Hand in one of the Scenes.public class ExampleClass : MonoBehaviourpublic GameObject hand;voidExample()// This returns the GameObject named Hand.
hand = GameObject.Find("Hand");// This returns the GameObject named Hand.// Hand must not have a parent in the Hierarchy view.
hand = GameObject.Find("/Hand");// This returns the GameObject named Hand,// which is a child of Arm > Monster.// Monster must not have a parent in the Hierarchy view.
hand = GameObject.Find("/Monster/Arm/Hand");// This returns the GameObject named Hand,// which is a child of Arm > Monster.
hand = GameObject.Find("Monster/Arm/Hand");
Ejemplo 3: unidad encuentra gameobject por nombre
GameObject enemy = GameObject.Find("enemy");
Ejemplo 4: unidad de búsqueda de objeto de juego por nombre
//tagforeach(GameObject fooObj in GameObject.FindGameObjectsWithTag("foo"))if(fooObj.name =="bar")//Do Something//isimforeach(var obje inFindObjectsOfType(typeof(GameObject))as GameObject[])if(obje.name =="obje")//Do something...
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)