- Home /
No attribute with the name 'MenuItem' error? help please.
Hello everyone ive been trying to create a simple prefab creation button following the Walker Boys tutorial but even though it is exactly the same i get an error that says
Error BCE0064: No attribute with the name 'MenuItem' or 'MenuItemAttribute' was found (attribute names are case insensitive).
Ive looked around everywhere and only a few other people seem to have had the issue and one solution was to comment out the errors then un-comment them after the build but this just causes further errors after for this particular script.
The scripts are in the Editor folder and ive done everything correct, has something changed since those tutorials were made or is there a work around for this, or more likely have i screwed up somewhere? Any help would be greatly appreciated.
Thanks in advance.
@MenuItem ("Project Tools/Make Prefab #&_p")
static function CreatePrefab()
{
var selectedObjects : GameObject[] = Selection.gameObjects;
for(var go : GameObject in selectedObjects)
{
var localPath : String = "Assets/Prefabs/" + go.name + ".prefab";
print(localPath);
}
createNew(localPath);
}
static function createNew (localPath : String)
{
var prefab : Object = PrefabUtility.CreateEmptyPrefab(localPath);
PrefabUtility.ReplacePrefab(selectedObjects, prefab);
}
I tried the script. The @$$anonymous$$enuItem compiles fine on my machine. I got an error further down on line 16 because 'selectedObjects' is undefined.
Thanks and the selectedObjects is an easy enough fix but im still stumped about the @$$anonymous$$enuItem. What could be wrong with my setup that would cause this specific error?
Answer by FuzzyLogic · Aug 03, 2013 at 06:41 PM
I'm guessing that you copy and pasted from the walker boys tutorial because the code appears fine. Try deleting that space just after @MenuItem and before the '('. It may be an unrecognized character.
Hello and thank you for the reply. I didn't copy and paste it as it was on a video, but i have now tried to remove the space but it makes no difference i still get the same error :-S.
Your answer
Follow this Question
Related Questions
Why The player don't move? 0 Answers
Index array is out of range (following H&S tut) 2 Answers
Standard cutout shader. Pixely outline. 1 Answer
C# damage script help 1 Answer