Search Issue Tracker
By Design
Votes
0
Found in
2022.3.63f1
6000.0.51f1
6000.1.7f1
6000.2.0b5
6000.3.0a1
Issue ID
UUM-109237
Regression
No
Button OnClick event remains the same when the selected function is changed to private
Reproduction steps:
1. Open the attached “ButtonOnClickPrivate” project
2. Open the “Assets/Scenes/SampleScene” Scene
3. In the Hierarchy window, select “Button” GameObject (Canvas > Button)
4. In the Inspector window, observe that the OnClick event is set to “TestScript.testMethod”
5. In the “Assets/TestScript” script, change “testMethod” function from public to private
6. Repeat steps 3 and 4
Expected result: The OnClick event is no longer “TestScript.testMethod” since its private
Actual result: The OnClick event remains “TestScript.testMethod”
Reproducible with: 2022.1.0a1, 2022.3.63f1, 6000.0.51f1, 6000.1.7f1, 6000.2.0b5
Reproducible on: macOS Sequoia 15.5 (M1 Max), Windows 11
Not reproducible on: No other environments tested
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
- URP Realtime reflection probes do not update when RenderProbe() is being called once per second
- Addressable terrain shader variants are stripped from the Player
- [iOS] Debug.Log() appears as <private> in Console app
- UI stays in the background when it is disabled in simulator
- A wrong log file is attached when project is launched with a "-logFile" command line argument
Resolution Note:
Thank you for the detailed bug report and reproduction steps.
The behaviour described is by design. The OnClick event system does not remove references to methods when their accessibility changes (e.g., from public to private). This decision was made intentionally to avoid breaking existing event connections, which could lead to unexpected runtime errors or loss of functionality in user projects.
While private methods are not displayed in the Inspector for event selection, this is done to prevent clutter and ensure only appropriate methods are shown. However, once a method is assigned to an event (e.g., OnClick), the reference is preserved regardless of whether the method later becomes private. This helps maintain backward compatibility and avoids disrupting workflows where accessibility modifiers might change during development.
Kind Regards
Karl Jones
Staff Software Engineer