Version: 2017.2
public static GameObject FindWithTag (string tag);

Parámetros

tag La tag ha buscar.

Descripción

Devuelve un GameObject activo etiquetado con tag. Devuelve null si ningún GameObject fue encontrado.

Los tags deben ser declarados en el tag manager antes de ser usados. Una UnityException será lanzada si el tag no existe, o si es ingresada como tag una cadena vacía o con valor null.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public GameObject respawnPrefab; public GameObject respawn; void Start() { if (respawn == null) respawn = GameObject.FindWithTag("Respawn");

Instantiate(respawnPrefab, respawn.transform.position, respawn.transform.rotation); } }