strangely it’s all working, but I still see the error in my console and wondered if you could see why.
I’m basically creating an array of two audio clips which I’ve assigned in the inspector and which play on command as instructed, but for some reason I see the error, the clips play as I said and I’m thinking is there a way to avoid this error?
my script is below, have a gander…
public AudioClip[] warpSounds;
I have two audio clips files in that and in Start ()
if (warpSounds!=null) audio.PlayOneShot (warpSounds [0]);
It plays but that’s the line with the error and later in Update I play the other sound once a button is pressed etc
if (playwarpsound) audio.PlayOneShot (warpSounds [1]);
That’s fine also, but I have that error and you would think it wouldn’t play the audio file but it does, so I’m i trying to populate the array with something else first or what? please advise
I suggest two things, if you know that in the entire game you will have only those 2 Audio Clips, just create two different variables for each one and forget about that error line.
Another way is verifying that the actual audio clip is null, and not the entire array.
Instead of:
if (warpSounds!=null) audio.PlayOneShot (warpSounds [0]);
Do:
if (warpSounds[0]!=null) audio.PlayOneShot (warpSounds [0]);
Or even better:
foreach(AudioClip c in warpSounds){
if(c != null) {
audio.PlayOneShot(c);
}
}
If something does not work let me know, I didn’t try that code out.
I just upgraded a project from 4.5 to 4.6 and also see this error spammed in the editor:
IndexOutOfRangeException: Array index is out of range.
SyntaxTree.VisualStudio.Unity.Bridge.WinPath.Combine (System.String left, System.String right)
SyntaxTree.VisualStudio.Unity.Bridge.UnityProject.Folders ()
SyntaxTree.VisualStudio.Unity.Bridge.UnityProject+<>c__DisplayClass18.b__15 ()
SyntaxTree.VisualStudio.Unity.Bridge.UnityProject.ItemGroup (System.IO.TextWriter w, System.Action a)
SyntaxTree.VisualStudio.Unity.Bridge.UnityProject.Serialize (System.IO.TextWriter w)
SyntaxTree.VisualStudio.Unity.Bridge.ProjectFile.WriteIfNecessary (SyntaxTree.VisualStudio.Unity.Bridge.FileGenerationHandler generationHandler)
SyntaxTree.VisualStudio.Unity.Bridge.ProjectFilesGenerator.GenerateProjectFiles ()
SyntaxTree.VisualStudio.Unity.Bridge.ProjectFilesGenerator+<>c__DisplayClass1.<.cctor>b__0 ()
UnityEditor.EditorApplication.Internal_CallUpdateFunctions ()
UPDATE:
Looks like UnityVS needed to be reimported.