Skip to content

Instantly share code, notes, and snippets.

@is8r
Last active December 21, 2015 15:49
Show Gist options
  • Save is8r/6329157 to your computer and use it in GitHub Desktop.
Save is8r/6329157 to your computer and use it in GitHub Desktop.
任意のGameObjectやプログラムを探す
//FindWithTag
GameObject xxx = GameObject.FindWithTag("xxx");//single object, InspectorのTagに表示されている名称
xxx.SendMessage("action");
xxx.BroadcastMessage("action");
//FindGameObjectsWithTag
GameObject[] xxxs = GameObject.FindGameObjectsWithTag("xxx");//any objects, InspectorのTagに表示されている名称
foreach(GameObject xxx in xxxs)
Debug.Log(xxx);
//Find
GameObject xxx = GameObject.Find("/Actor/Xxx");//Hierarchyに表示されている名称
Debug.Log(xxx);
//GetComponent
XxxController xxxController = xxx.GetComponent<XxxController> ();
Xxx xxx = GetComponent <Xxx> ();
Xxx xxx = GetComponentInChildren <Xxx> ();
Text xxx = GetComponent <Text> ();
Animator xxx = GetComponent <Animator> ();
AudioSource xxx = GetComponent <AudioSource> ();
//FindObjectOfType
XxxController xxxController = FindObjectOfType<XxxController> ();
//RequireComponent
[RequireComponent(typeof (XxxController))]
public class GameController : MonoBehaviour {
private XxxController xxxController;
void Start () {
xxxController = GetComponent<XxxController> ();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment