Copyright © 2026 Unity Technologies
Steps to reproduce:
Actual result:
After step 2, "SelectionExtensions loaded" is logged, followed by an error, an exception and a warning:
Exception while executing InitializeOnLoad for <G>$2F3C250B88281DE478596FD76BA636C8.OnEditorLoad NotSupportedException: Specified method is not supported. Cannot add menu item 'Tools/Log Selection Count' for method 'SelectionExtensions.LogSelectionCount' because a menu item with the same name already exists.
After step 3, "Selection count" is not logged; instead:
NotSupportedException: Specified method is not supported.
After step 4, "Game started" is logged, followed by:
NotSupportedException: Specified method is not supported.
Expected result: Each method runs once with no errors: "SelectionExtensions loaded" after step 2, "Selection count: 0" after step 3 and "Game started" after step 4
Stack trace:
at SelectionExtensions.<G>$2F3C250B88281DE478596FD76BA636C8.OnEditorLoad() at System.RuntimeMethodHandle.InvokeMethod(ObjectHandleOnStack target, Void** arguments, ObjectHandleOnStack sig, BOOL isConstructor, ObjectHandleOnStack result) at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at UnityEditor.EditorAssemblies.ProcessInitializeOnLoadMethodAttributes()
Reproducible with versions: 7000.0.0a22
Can't test with versions: 6000.0.86f1, 6000.3.29f1, 6000.6.11f1, 6000.7.0b11, 7000.0.0a21 (C# 14 extension blocks are not available: the scripts fail to compile with "error CS1001: Identifier expected")
Tested on (OS): macOS 27.0 (Apple M1 Max, arm64)
Issues you vote on will appear here