using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 通过标签查找对象
/// </summary>
public class GameObject_FindWithTag : MonoBehaviour
{
// 定义对象
private GameObject cubeObject;
private GameObject sphereObject;
private GameObject cylinderObject;
void Start()
{
// 查找标签
cubeObject = GameObject.FindWithTag("CubeTag");
sphereObject = GameObject.FindWithTag("SphereTag");
cylinderObject = GameObject.FindWithTag("CylinderTag");
// 输出标签
Debug.Log(cubeObject.tag);
Debug.Log(sphereObject.tag);
Debug.Log(cylinderObject.tag);
}
void Update()
{
}
}