Trouble finding GameObject in a script that is on an Empty brought over from previous scene
So I have an empty that is holding scripts. This is initiated on the first level (menu) I then use DontDestroyOnLoad to bring it through to the next level as it has some script functions that need to be executed in that scene.
Where I am having the trouble is trying to find GameObjects in that next level.
public void ClickStartSeq (){
//Pulls in tracking data for each object
GameObject PhoneTrack = GameObject.Find("PhoneData");
Debug.Log(PhoneTrack);
//PhoneTrackingData = PhoneTrack.GetComponent<CornerPinData3>();
GameObject HelmetTrack = GameObject.Find("HelmetTrack");
Debug.Log(HelmetTrack);
//HelmetTrackingData = HelmetTrack.GetComponent<CornerPinData3>();
GameObject JerseyTrack = GameObject.Find("JerseyTrack");
Debug.Log(JerseyTrack);
//JerseyTrackingData = JerseyTrack.GetComponent<CornerPinData3>();
GameObject AutographTrack = GameObject.Find("AutographTrack");
Debug.Log(AutographTrack);
//AutographTrackingData = AutographTrack.GetComponent<CornerPinData3>();
//GameObject TunnelTrack = GameObject.Find("TunnelTrack");
//Debug.Log(PhoneTrack);
//TunnelTrackingData = TunnelTrack.GetComponent<CornerPinData3>();
GameObject VideoAudio = GameObject.Find("VIDEO");
AudioSource audio = VideoAudio.GetComponent<AudioSource>();
audio.Play();
StartCoroutine(StartSeq()) ;
This method is called on a button click after the scene has loaded.
What is weird is that according to my Debug, the HelmetTrack and the AutographTrack are being found, where as the others are returning a null value.
Any ideas on what the issue is would be much appreciated!!
Your answer
Follow this Question
Related Questions
How Can I assign a gameobject via script? 0 Answers
How can I destroy a GameObject after a scene is loaded? 1 Answer
Why does GameObject.Find() work in ones and not in others? 1 Answer
Destroy object when a new scene loads 0 Answers
setting a variable to a GameObject that has a certain RGB value??? please help 0 Answers