Hello everyone,
I’m having trouble with an Array and I hope that somebody has an idea.
I’ve written an AudioControl Script to load Music into an Array.
public AudioClip[] mClips;
mClips = Resources.LoadAll<AudioClip> ("Audio/Music");
This works fine. In my MainMenu Scene and MainMenu.cs Script, I can play the music by script.
To check the array I made a Debug.Log.
foreach (AudioClip getTheClips in audioControl.mClips)
Debug.Log ("MainMenu: " + getTheClips);
The result in my console is fine:
MainMenu: Soft1 (UnityEngine.AudioClip)
MainMenu: Stage1 (UnityEngine.AudioClip)
When I start the Game and switch the Scenes from MainMenu to Level_00 by SceneManger.LoadLevel the Array is used in my HealthController.cs
In the HealthController.cs I did the following to check the Array:
foreach(AudioClip theClips in audioControl.mClips)
Debug.Log ("HealthController: " + theClips);
The result in console is just: HealthController:
No Error Message or Warning.
If I try:
public AudioClip levelMusic;
levelmusic = audioControl.mClips [1];
Debug.Log = (levelmusic);
It returns just “Null” in Console.
public AudioControl audioControl;
//In Startfunction on both Scripts
audioControl = GetComponent<AudioControl> ();
Any help is appreciated.