- Home /
[Solved] why dosen't Unity 4.6 New UI button work when you instantiate it on playmode?
when you dynamically instantiate a button it wont work in play mode.but if you instantiate it on edit mode its works. is this a unity 4.6 bug? the UI button script seams to fail at triggering e.g highlight color , pressed color etc.. i already tried searching everywhere it seams nobody asked the question yet.
p.s the instantiated button is in the canvas
Extra tags for search-ability . Unity , UI , cloning , button , canvas , drop , down ,Unity 5 , menu , vertical menu , horizontal menu , Gird Menu , instantiate , Duplicate , run time , play mode, edit mode , event trigger , event system , onhover , onEnter , onPointer , OnExit , Event listener
Answer by Kiwasi · Nov 20, 2014 at 05:05 AM
I've answered this question three times already this week. :) Its a well known fact that searchability of UA sucks.
There are a couple of things to check when instantiating a button
The button must be the child of a canvas
There must be an event system present in the scene
You have to add listeners via script
To see a video where I write a script that does all of this check out my YouTube video here.
WOW thank you.. i can't believe UA is like that might be because UA isn't as strict as stackoverflow but at least UA is very welco$$anonymous$$g if i had to ask this on overflow ill get down voted right way. anyway thanks a lot :)
Wow, just spent an hour digging into this one. I must have deleted my event system accidentally. Thanks a ton.
Answer by cariaga · Nov 21, 2014 at 03:36 AM
ALTERNATIVE SOLUTION
it is actually a version problem in unity 3D 4.6b7 doesn't support button instantiate where it includes the listener BUT this can be fixed by updating unity3D that is if the dynamic button instantiation is the problem