The condition never true when I run it over and over. Please take a look the script.
This is not full script but this will be enough to know how the condition check is going on.
The error is happen when if ((result*+“.wav”) == voicefile)*is checked. Can anyone help me out with this?? The condition must be true because both are “a.wav” (string). ```csharp
*public static List voicefilelist = new List();
string result;
for (int i = 0; i < result.Length; i++)
{
for (int ii = 0; ii < voicefilelist.Count; ii++)
{
string voicefile = voicefilelist[ii].ToString();
if ((result[i]+“.wav”) == voicefile)
{
selected = voicefilelist[ii];
print("Selected: "+selected);
voice.PlayVoice(selected);
flag = 1;
break;
}
}
if (flag == 1)
{
continue;
}
}*
Clearly not the file name of a .wav file, as you seem to be expecting. You probably want something more like AudioClip.name, but even that won’t have the file extension on it.
String comparisons are always fun ones as there are many cases where it isn’t true, including caps, spaces, and other things. But as mentioned, debug the values to make sure they are indeed matching.
I just tested out right now and found that the audioclip.name actually give the file name with extension(“a.wav”). So, I got pure String which can check condition with the other String in if condition checking. Thank again everyone.