Returns the first active loaded object of Type type
.
// Search for any object of Type GUITexture, // if found print its name, else print a message // that says that it was not found. function Start() { var texture : GUITexture = FindObjectOfType(GUITexture); if(texture) Debug.Log("GUITexture object found: " + texture.name); else Debug.Log("No GUITexture object could be found"); }
using UnityEngine; using System.Collections; public class Example : MonoBehaviour { void Start() { GUITexture texture = FindObjectOfType(typeof(GUITexture)); if (texture) Debug.Log("GUITexture object found: " + texture.name); else Debug.Log("No GUITexture object could be found"); } }
import UnityEngine import System.Collections public class Example(MonoBehaviour): def Start() as void: texture as GUITexture = FindObjectOfType(typeof(GUITexture)) if texture: Debug.Log(('GUITexture object found: ' + texture.name)) else: Debug.Log('No GUITexture object could be found')