跳到主要内容

GetGameObjectByTag

描述​

通过标签找到游戏对象

参数​

ParamType描述
_tagString独一无二的名称
_gameObjectGameObject(out)搜索结果

方法​

警告

你必须将GameObjectRuntimeTag脚本添加到你将用于检索的gameObject中,并在GameObjectRuntimeTag.RuntimeTag字段中输入Tag。

public void GetGameObjectByTag(string _tag,GameObject _gameObject)

例子​

private void OnLoad(){
RuntimeTagManager.GetRuntimeTagManager.GetGameObjectByTag("Player",out GameObject tmp_Player);
if(tmp_Player.GetComponent<IRuntimeTag>().DoCompareTag("Player")){
Debug.Log(tmp_Player.name);
}
}