GameObject.FindWithTag
Deklarasyon
public static GameObject FindWithTag(string tag);
Parametreler
tag | Aranacak etiket. |
Açıklama
tag ile etiketlenmiş bir aktif GameObject döndürür. Eğer bir GameObject bulunamazsa null döndürülür.
Etiketler kullanılmadan önce etiket yöneticisinde tanımlanmalıdır. Etiket mevcut değilse veya boş bir dize ya da null etiket olarak geçirilirse bir UnityException fırlatılır.
Not: Bu metod, belirtilen etiketle bulduğu ilk GameObject'i döndürür. Eğer bir sahne belirtilen etiketle birden fazla aktif GameObject içeriyorsa, bu metodun belirli bir GameObject döndüreceğine dair bir garanti yoktur.
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); } }
Bu blog Unity Docs'un Türkçeye çevrilmiş halidir.
Yorumlar
Yorum Gönder