FindWithTag error
Hi guys,
I'm trying to access the component of a GameObject BUT my main script "GlobalSceneManager" that is in "DontDestroyOnLoad". From this script I want to access the component of a GameObject that is in the current scene played called "Calibration".
Is it possible to do that ?
My (uncompletd) main script here:
public class GlobalSceneManager : MonoBehaviour {
private ActiveSound activeSound;
void Update() (include a switch)
case GameState.CALIBRATION:
if (dataC.calibDone = true & _elapsedTime >= 40)
{
SceneManager.LoadScene("Calibration");
activeSound = GameObject.FindWithTag("Instruction").GetComponent<ActiveSound>();
instructionVMax = activeSound.instructionCalibrationVMax;
//instructionVSpont = activeSound.instructionCalibrationVSpont;
audioInstruction = GameObject.FindWithTag("Instruction").GetComponent<AudioSource>();
audioInstruction.clip = instructionVMax;
audioInstruction.Play();
My script ActiveSound is in the GameObject "Instruction" that is in the scene "Calibration".
public class ActiveSound : MonoBehaviour
{
//public AudioClip[] instructionCalibration;
public AudioClip instructionCalibrationVMax;
public AudioClip instructionCalibrationVSpont;
}
The global aim is to be able to switch the instruction between my two calibration scenes that I have to play. I want a unique scene Calibration but my globalSceneManager has to play 2 times the calibration scene with two different audio instruction. Maybe there is a better way to do this... I'm new in Unity.
Thank a lot.
Take care of you.
AL
Your answer
![](https://koobas.hobune.stream/wayback/20220612225626im_/https://answers.unity.com/themes/thub/images/avi.jpg)