Search Unity

Bug MenuItem is not removed if script is changed/erased

Discussion in 'Linux' started by Chaoseiro, Sep 17, 2015.

  1. Chaoseiro

    Chaoseiro

    Joined:
    Aug 28, 2013
    Posts:
    40
    Title is pretty self-explanatory, but here are some screenshots:
    SS01:

    SS02:


    Steps to reproduce:
    • Create a new, empty project
    • Create an Editor folder inside the Assets folder
    • Create a new C# script
    • Write any code that asks for a MenuItem, like the following:
      Code (CSharp):
      1. using UnityEditor;
      2.  
      3. public class AddMenu {
      4.  
      5.     [MenuItem("Test/Test Menu")]
      6.     public static void AMenuItem() {
      7.         UnityEngine.Debug.Log("Hay");
      8.     }
      9. }
    • Save, Unity will compile and it will work as expected [See SS01]
    • Open the script, comment out the code (or erase the script)
    • The late MenuItem will still show up in the global menu, but placed before any other menu and trying to execute it will give
      NullReferenceException: Object reference not set to an instance of an object
      UnityEditor.TerrainTreeContextMenus.EditTreeCheck (UnityEditor.MenuCommand item) (at /home/builduser/buildslave/unity/build/Editor/Mono/TerrainEditor/TerrainMenus.cs:233)

      [See SS02]
    In another project it crashed the editor, but the crash didn't happen with a blank project.