public static Object FindObjectOfType (Type type);

パラメーター

type 見つけるオブジェクトの型

戻り値

Object This returns the Object that matches the specified type. It returns null if no Object matches the type.

説明

タイプ type から最初に見つけたアクティブのオブジェクトを返します

using UnityEngine;
using System.Collections;

// Search for any object of Type GUITexture, // if found print its name, else print a message // that says that it was not found. public class ExampleClass : MonoBehaviour { void Start() { GUITexture texture = (GUITexture)FindObjectOfType(typeof(GUITexture)); if (texture) Debug.Log("GUITexture object found: " + texture.name); else Debug.Log("No GUITexture object could be found"); } }