- Home /
 
               Question by 
               MJG1123 · May 22, 2017 at 01:20 AM · 
                gameobjectfindgameobject.findobject reference  
              
 
              gameobject.find custom class
how can I do something similar to this
public 2ndScript SndScript
void awake () { sndScript = GameObject.Find("2ndScriptObject"); }
               Comment
              
 
               
              Please... craft your questions better, also this is a very basic question, a quick google search should of given you the answer. If you 2ndScript is a $$anonymous$$onoBehaviour, you can do this.
 public class SecondClass : $$anonymous$$onoBehaviour
 {
     public int randomData;
 }
and
 public class FirstClass : $$anonymous$$onoBehaviour
 {
     public SecondClass secondClass;
     void Awake()
     {
         secondClass = FindObjectOfType<SecondClass>();
     }
 }
I highly suggest against using GameObject.Find calls, they are expensive, unnecessary, and build bad coding habits. There are a lot better ways of doing this. Like singleton and management classes.
Your answer
 
 
             Follow this Question
Related Questions
GameObject.Find() Question 1 Answer
Finding object with transform 1 Answer
GameObject.Find, When it is Called? 1 Answer
Find one inactive player (gameobject) 2 Answers
Separate objects from GameObject[] group 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                