Cube Detection

Vision sensor is the best, it will detect size and color.

Light sensor without bright light source is useless for this.

Line sensor has its own infrared led. It works best <0.5" from the cube.
But you have to shield it from direct exposure or you are screwed: Sacramento State Management & Venue Problems

Finally, if all you need is to detect if cube is inside the robot, then limit switch is you most reliable friend.