Need to be able to find all objects via their script (in unity)

I need to find an object via a script that it has attached. I am trying to use FindObjectOfType. My current code:

void Start () { hex1 = Object.FindObjectOfType<hex1> (); } the first hex1 is the object, the second is the script attached to the object I have to find. If you know why this is wrong or if you have a better way of doing this please tell me. Thanks

by Yayhappyface via /r/csharp

Leave a Reply