Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: vexir on August 22, 2013, 04:52:21 PM
-
I'm trying to dynamically create ImageButtons in a HUD manager script. I have a prefab of an imagebutton, and after using AddChild() to instantiate and add that prefab to a panel, I change it's sprite and other properties to my liking. For a while though, the buttons weren't responsive. It turns out the box collider was scale 1 and position 0 and other default things, but a ImageButton that I created through the Widget Tool would have a box collider that closely matched the size and position of the button. I fixed it by removing the prefab's box collider and calling NGUITools::AddWidgetCollider, but I'm wondering why AddChild doesn't update a prefabs box collider for you?
-
AddChild adds the object as-is. It won't adjust the collider. You can adjust the collider just by calling AddWidgetCollider (no need to remove it first, it will just update it if it's present)