Author Topic: AddChild Doesn't update a prefab's Box Collider  (Read 3588 times)

vexir

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 47
    • View Profile
AddChild Doesn't update a prefab's Box Collider
« 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?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: AddChild Doesn't update a prefab's Box Collider
« Reply #1 on: August 23, 2013, 02:57:33 PM »
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)