Search Issue Tracker
Fixed in 4.6.2
Votes
3
Found in
4.6.1p2
Issue ID
661334
Regression
Yes
[Button] Null references when passing gameObjects as parameters to functions called by the OnClick events
Steps to reproduce this issue:
1. Open the attached project
2. Open 'Scene'
3. Play the scene
4. Press on the button
5. Notice 'NullReference' exception
6. Select 'Acivate Menu A' button and try to assign 'Menu A' gameObject to the OnClick parameter
7. Notice it does not recognize it properly
Regression since 4.6.1p2, worked in p1
Captured here: http://screencast.com/t/P7hcUB4OCE
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
- A Console error is not handled correctly when using #pragma kernel with the Kernel name not provided
- L(a,b) expression in float fields has erratic behaviour when ordering due to using instanceID as an index
- InvalidOperationException is thrown when switching to a custom Debug Draw Mode in Scene View
- [Android][Vulkan] Skybox and Environment effects flicker in the Player when using the Vulkan Graphics API
- "Shortcuts conflict" warning pops up when the shortcuts are different ("Shift + Mouse 2" and "Mouse 2")
ugurozsahin
Feb 25, 2015 11:57
Not solved in version 4.6.3.f1to
WesleyNasray
Feb 16, 2015 17:47
Ops, dind't understand the comments when I first read. Just need to patch:
http://unity3d.com/unity/qa/patch-releases
WesleyNasray
Feb 16, 2015 17:45
Got this problem after Updating to 4.6.2.f1.
Items dragged to a UnityEvent treat everything as GameObjects insted of getting the expected Component that the Method requires.
A way to bypass this problem while not resolved is to create/copy the Component (e.g. Button) on the target object, then drag its target Component to the UnityEvent field (e.g. OnClick) and then copy back this Component (Button) to the original object.
Henning_Justare
Feb 06, 2015 07:53
Finally fixed :) As ODYSSEY96 said it's fixed in 4.6.2p1 :)
odyssey96
Feb 05, 2015 23:14
Oh just seen this is apparently fixed in 4.6.2p1 which im downloading now so if any of you guys come back here you should go to the patch download section :)
odyssey96
Feb 05, 2015 22:54
Right this works - although I cant believe its possible to maintain this. If you add the required component to the button itself, this will allow you to drag the component to the onclick parameter and then it will display the Name of Object (Component) as the parameter like before. When the method is called, the parameter is not null.
This really seems to me before the editor would do a getcomponent on the dragged in object to get the component instance, now it is not doing that. If you drag the actual component in, that works fine. but i dont think you can drag the component of any other object than the current selected object as if you have multiple inspector windows, they both change when the selected object in the heirachy is changed.
odyssey96
Feb 05, 2015 22:34
Same issue, just updated from 4.6.1 p1 to experience this. Now here's the thing - references set before the update work fine.
Before, references would have the component after i.e. If you specified 'MenuController' as a argument of a behaviour method, point to to this method in the onclick event and then drag an object containing a MenuController component, it would say Name Of Object (MenuController). And it still does for existing references I made in the 4.6.1 version!
Now they just display the name of the object and end up as null variables. Could it be that the editor is not performing a getcompoent call on the object you're passing??
yoziva
Feb 05, 2015 19:26
Same here. Not fixed in unity 4.6.2f1.
We cannot vote on this one, should we create a new issue ?
While waiting for the fix a workaround could be to change the type of the parameter to a gameobject (instead of the component type), and get desired component inside the method.
hmortensen2907
Jan 29, 2015 19:41
Not solved in 4.6.2.f1 as stated :(
Items dragged into OnClick parameter is still treated as GameObject, and not the type of the receiving method.
How do we/I change Status: Fixed to not Fixed?