how to solve in this error "The name `CowboyRap' does not exist in the current context" .using below script

using UnityEngine;
using System.Collections;

public class Audio_RanGen : MonoBehaviour
{

public AudioClip[] sound=new AudioClip[1]{CowboyRap};


// Use this for initialization
void Start ()
{
	
}

// Update is called once per frame
void Update () 
{
 
}



void OnGUI()
{
	
	if(GUI.Button(new Rect(100,200,200,50),"Random Number Genaration"))
	{
		
		
		for(int i=0;i<14;i++)
		{
			print ("hiiii");
			print(sound.Length);
			print(sound[0]);
			audio.clip=sound[Random.Range(0,sound.Length)];
			audio.Play();
			
		}
		
		
	}
	
	
	
}

}

declare CowboyRap.

1 Answer

1

I’m assuming “CowboyRap” is the name of an audio clip file?

If so, try changing to:

public AudioClip[] sound=new AudioClip[1];

Then, in the inspector, drag the file to the “AudioClip” property that should show up.