Make UI element only appear if object is present (unity 4.6)

I have an energy bar that only applies to a certain item, and so i want it to disappear whenever the object is not present.

one option is to attach your UI element to your gameobject so when it destroys the ui element will disappear