A versatile strategy for uniform hybrid nanoparticles and nanocapsules