Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

No attribute with the name 'MenuItem'

Discussion in 'Scripting' started by Shadowing, Feb 8, 2015.

  1. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,628
    I got this ajax script off the asset store and it worked great until I went to hit build
    and its giving me error

    No attribute with the name 'MenuItem' or 'MenuItemAttribute' was found (attribute names are case insensitive).

    Anyone have any ideas on this

    Much thanks.


    Code (csharp):
    1.  
    2.  
    3. /* Create menu option for toggling Ajax output */
    4. @MenuItem ("GameObject/Aptus Ajax/Toggle Display in Current Scene")
    5. static function ToggleOutput ()
    6. {
    7.  var instructions:String;
    8.  var ajax:Ajax = Ajax.GetAjax (); /* This comment is only here so I can use the word "ajax" yet one more time on this line... */
    9.  if (ajax.ToggleOutput ())
    10.  {
    11.  instructions = "Message display for Aptus Ajax has been enabled in the current scene.  Please note that this will only ";
    12.  instructions += "affect the current scene, and any other scenes using Ajax may still have message display turned off. ";
    13.  instructions += "Also, you must save the current scene in Unity to make this change permanent.";
    14.  EditorUtility.DisplayDialog ("Toggle Aptus Ajax Message Display in Current Scene", instructions, "Ok");
    15.  }
    16.  else
    17.  {
    18.  instructions = "Message display for Aptus Ajax has been disabled in the current scene.  Please note that this will only ";
    19.  instructions += "affect the current scene, and any other scenes using Ajax may still have message display turned on. ";
    20.  instructions += "Also, you must save the current scene in Unity to make this change permanent.";
    21.  EditorUtility.DisplayDialog ("Toggle Aptus Ajax Message Display in Current Scene", instructions, "Ok");
    22.  }
    23. }
    24.  
    25.  
    26.  
     
  2. Zerot

    Zerot

    Joined:
    Jul 13, 2011
    Posts:
    135
    Put the script in a folder called Editor. That way it will end up in the Editor assembly and will not be included in builds.
     
    Xepherys likes this.
  3. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,628
    Thanks Zerot I appreciate it
     
    visallpii likes this.
  4. visallpii

    visallpii

    Joined:
    Oct 17, 2016
    Posts:
    1
    This solution works thank YOU