GameObject.FindWithTagstatic function FindWithTag (tag : String) : GameObjectDescriptionReturns one active GameObject tagged tag. Returns null if no GameObject was found. Tags must be declared in the tag manager before using them.
JavaScripts
// Instantiates respawnPrefab at the location
// of the game object with tag "Respawn" var respawnPrefab : GameObject; var respawn = GameObject.FindWithTag ("Respawn"); Instantiate (respawnPrefab, respawn.transform.position, respawn.transform.rotation); using UnityEngine;
using System.Collections; public class example : MonoBehaviour { public GameObject respawnPrefab; public GameObject respawn = GameObject.FindWithTag("Respawn"); void Awake() { Instantiate(respawnPrefab, respawn.transform.position, respawn.transform.rotation) as GameObject; } } import UnityEngine
import System.Collections class example(MonoBehaviour): public respawnPrefab as GameObject public respawn as GameObject = GameObject.FindWithTag('Respawn') def Awake(): (Instantiate(respawnPrefab, respawn.transform.position, respawn.transform.rotation) as GameObject) |
