using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 游戏对象的类
/// 场景中所有的对象
/// </summary>
///
public class CubeGameObject : MonoBehaviour {
// 定义一个对象变量,用于保存对象
public GameObject cubeGameObject;
public GameObject sphereGameObject;
public GameObject cylinderGameObject;
private void Start()
{
cubeGameObject = GameObject.Find("Cube");
sphereGameObject = GameObject.Find("Sphere");
cylinderGameObject = GameObject.Find("Cylinder");
Debug.Log(cubeGameObject.name);
Debug.Log(sphereGameObject.name);
Debug.Log(cylinderGameObject.name);
}
private void Update()
{
}
}
【Unity】GameObject中的Find 2020/11/25 小雨
最新推荐文章于 2024-05-28 16:42:42 发布