Search Issue Tracker
Fixed in 5.0.X
Votes
0
Found in
5.0.0b18
Issue ID
660985
Regression
Yes
[ContextMenu]If a script is derived from a MonoBehaviour defined in an assembly, calling a [ContextMenu] function causes error
Steps to reproduce this issue:
1. Open the attached project
2. Open 'test' scene
3. Select 'test' gameobject, it has 3 components
4. Click the context menu of each one:
-TestContextMenu logs properly ('bla')
-TestContextMenuInAssembly logs properly ('bla')
-TestContextMenuDerivedFromAssembly throws the error : "Failed to call function because it was null"
Regression since b9
Comments (1)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- var VisionOSEDRHeadromm has a comma instead of a dot when building with Metal Rendering App Mode and local OS localization is set to German
- IAP Catalog remove product “x” and add product “+” buttons are not consistent with other remove and add buttons in the Editor
- Performance issues in Play Mode when quickly hovering the mouse cursor over Hierarchy GameObjects
- Frame Debugger displays incorrect output when FidelityFX Super Resolution or Spatial-Temporal Upscaler is used with Temporal Anti-aliasing or Subpixel Morphological Anti-aliasing
- The layout system is failing to correctly calculate or apply the height of the Japanese fallback font when the primary English font's metrics are used
hutchison-kim
May 20, 2015 16:08
I got this error using different repro steps:
1. Declare a MonoBehavior class (MyClass).
2. Declare a function (MyFunc) that has a ContextMenu attribute in class (MyClass).
3. Declare a sub-class (MySubClass) that derives from the previously declared class (MyClass).
4. Add a component of type subclass (MySubClass) to a GameObject.
5. Right-Click on the component and run the function (MyFunc) from the context menu.
6. Error: "Failed to call function because it was null".
Steps to work around this issue:
1. Declare a MonoBehavior class (MyClass).
2. Declare a *virtual* function (MyFunc) that has a ContextMenu attribute in class (MyClass).
3. Declare a sub-class (MySubClass) that derives from the previously declared class (MyClass).
4. Declare a *override* function (MyFunc) for the previously declared virtual function.
5. Add a component of type subclass (MySubClass) to a GameObject.
6. Right-Click on the component and run the function (MyFunc) from the context menu.
7. Success.