Hi,
I'm adding 'Audio Track' (custom class) elements to a list, and storing that list in an asset to be saved/loaded.
It adds AudioTracks to the list by detecting them in the scene, for which I have another serialised list called 'sceneSources'
**This is the function that adds to the list:**
if (GUILayout.Button ("Search Scene")) {
//Search for audio sources in scene
am.sceneSources = GameObject.FindGameObjectsWithTag("Audio").ToList();
for (int i = 0; i < am.sceneSources.Length; i++)
{
am.trackList.Add(new AudioTrack(am.sceneSources[i].name, am.sceneSources[i].audio.volume, am.sceneSources[i].audio.pan));
}
}
It works, initially, it adds all the elements properly from the hierarchy (and allows me to control them, by looking at the 'sceneSources' of the same index, but in the inspector of the .asset file, the 'in scene objects' have type mismatch. So upon closing and reopening unity, my objects aren't connected, and I get a reference error. Upon repoening it says **'None (GameObject)'**
![alt text][1]
[1]: /storage/temp/34038-inspector.png
↧