BoundBox not working after being attached to GameObject using script

I'm trying to use BoundBox component for my project.When I attach BoundBox using inspector it works fine.But when I try to attach it to a generated cube, using script, the cube gets created and shows the BoundBox component under inspector but doesn't actually work.