お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Closetag | 検索するためのタグ |
/tag/でタグ付けされたアクティブなゲームオブジェクトを返します。もし見つからない場合は null
を返します
この関数を使用する前にタグマネージャーでタグの設定を行う必要があります。タグが存在しない、または空文字や null
を渡した場合は UnityException
の例外が発生します。
var respawnPrefab : GameObject; var respawn: GameObject; // Instantiates respawnPrefab at the location // of the game object with tag "Respawn" // This example assumes that a game object is tagged with "Respawn" function Start() { if (respawn==null) respawn = GameObject.FindWithTag ("Respawn"); Instantiate (respawnPrefab, respawn.transform.position, respawn.transform.rotation); }
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) as GameObject; } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): public respawnPrefab as GameObject public respawn as GameObject def Start() as void: if respawn == null: respawn = GameObject.FindWithTag('Respawn') (Instantiate(respawnPrefab, respawn.transform.position, respawn.transform.rotation) as GameObject)