言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

GameObject.FindWithTag

Suggest a change

Success!

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.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static function FindWithTag(tag: string): GameObject;
public static GameObject FindWithTag(string tag);
public static def FindWithTag(tag as string) as GameObject

Parameters

tag 検索するためのタグ

Description

/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)