@script RequireComponent(AudioSource) does not work

Hi,

I´m going through the Unity Game Dev Essentials right now and having a little problem with the

@script RequireComponent(AudioSource)

command.

It simply doesn´t work. In Chapter 8, there is this simple script:

var levelToLoad : String;
var normalTexture : Texture2D;
var rollOverTexture : Texture2D;
var beep : AudioClip;

function OnMouseEnter(){
	guiTexture.texture = rollOverTexture;
}

function OnMouseExit(){
	guiTexture.texture = normalTexture;
}

function OnMouseUp(){
	audio.PlayOneShot(beep);
	yield new WaitForSeconds(0.35);
	Application.LoadLevel(levelToLoad);
}

@script RequireComponent(AudioSource)

which should add an Audio Source component to an object, after the script is added. Well, it doesn´t work for some reason and I can´t find out why. Anyone knows what could cause it not to appear in the inspector ? :frowning:

Thanks for help in advance !

Did you already have the script attached before adding the RequireComponent line? I think it only adds the object at the point the script is applied to the object.