Comment by Scribe
[Check here][1] Note: using the answer here will still not update in the gui as the listeners added in scripts are of a different type to those added from the gui (non-persistent rather than...
View ArticleComment by Eoghan
I did actually read through that - that's where I got the above script from. I can't see where it's going wrong - and I'm not being returned any errors or the likes. The script is set up to generate...
View ArticleAnswer by wowipop
Transform purchaseButton = newItem.transform.FindChild("Purchase"); if (purchaseButton != null) { Debug.Log("found button"); UnityEngine.Events.UnityAction action1 = () => {...
View ArticleComment by Eoghan on Eoghan's answer
Unfortunately, this didn't work either. No compile/runtime errors or anything; the buttons just aren't doing anything when clicked. Any other ideas?
View ArticleComment by Scribe
Have you tried doing it in the lambda expression way as shown on that question as opposed to how you have done it above? AddListener(() => { btnClicked("testarg"); });
View ArticleComment by fmoo
Did you ever figure this out? I'm running into a similar issue and it looks kind of like a race condition.
View ArticleComment by rainbow_design on rainbow_design's answer
I have a similar problem where it does not work
View ArticleAnswer by Drakoran
I also ran into this issue. Somehow, I unchecked the Raycast target on the image script. Checking this allowed the onClick.AddListener() to work. .onClick.AddListener(() => TestAddition()); private...
View ArticleComment by Shadowing on Shadowing's answer
This doesn't work still if you do GetComponent(Button) I already have Raycast checked on the image script
View ArticleComment by Piflik
I have encountered the same problem. I tried UnityEvent and System.Action, but both fail to register, when they are on an instantiated prefab. I use nearly identical code on other objects, that are...
View ArticleComment by rjeike
I had this problem and it turns out that I didn't have an EventSystem in the scene. Adding an EventSystem object resolved it for me.
View ArticleAnswer by HedgeWizard137
Here is what I did. I had a prefab button I want to Instantiate and then addListener, but what I did was add the listener to the prefab and not to the clone I just Instantiated. public GameObject...
View ArticleAnswer by erofes
Hi there! I have one solution for someone who encounters the same sort of the problem. If you want to create Prefab of game object, which will contain button or buttons as components of parent itself,...
View ArticleAnswer by misher
First, don't use Transform.FinsChild, it is deprecdated, you can look straight for a button component in a child. Second, use simple lambda function if you want to pass a parameter to other methos. ......
View ArticleAnswer by Icephoenix31
The previously listed solutions didn't seem to work for me, so here is what I came up with. My problem anyway seemed that it tried to add the listener after the button was pressed and by that time, the...
View Article