Hello! Question: When I put a texture as the first element (element 0) in the texture sound array or the elements preceeding it have no texture assigned, it recognizes it and plays the corresponding sound, however when it is not the first element (element 0), it will go straight to GetClipNullClip(), even though it shouldn’t because the texture is properly assigned. Any ideas? If I’m missing something please let me know!
IEnumerator PlayFootstepFromRenderer(Renderer Renderer)
{
if (stepCycleProgress > distanceBetweenSteps)
{
stepCycleProgress = 0f;
foreach (TextureSound textureSound in TextureSounds)
{
if (textureSound.Albedo == Renderer.material.GetTexture("_MainTex"))
{
texInList = true;
AudioClip clip = GetClipFromTextureSound(textureSound);
audioSource.PlayOneShot(clip);
//texInList = false;
yield return new WaitForSeconds(clip.length);
break;
}
if (!texInList)
{
AudioClip clip = GetClipNullClips();
audioSource.PlayOneShot(clip);
yield return new WaitForSeconds(clip.length);
break;
}
}
}
}
private AudioClip GetClipNullClipsForJumpLand()
{
return GetClipFrom(NullClipsJumpLand);
}
private AudioClip GetClipFrom(AudioClip[] clips)
{
int clipIndex = Random.Range(1, clips.Length);
AudioClip temporary = clips[clipIndex];
clips[clipIndex] = clips[0];
clips[0] = temporary;
return temporary;
[System.Serializable]
private class TextureSound
{
public Texture Albedo;
public AudioClip[] Clips;
public AudioClip[] JumpClips;
}
}