FindObjectsOfType()

代码演示:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FindObjectOfType : MonoBehaviour {

private GameObject[] things;
private GameObject thing;

void Start () {

things = FindObjectsOfType<GameObject>();
thing = FindObjectOfType<GameObject>();

Debug.Log("第一个" + thing.name);
for(int i = 0; i < things.Length; i++)
{
Debug.Log(things[i].name);
}
}
}
--------------------- 

posted @ 2019-07-31 17:52  李艳艳665  阅读(723)  评论(0编辑  收藏  举报