Tito and his charisma were a great contribution to the unity up to 1980. Furthermore, the more recent intellectual & pan-slavic movements within Bosnia & Hercezogina and the Kingdom of Serbia, alongside Croatia helped for a youth oriented movement towards a union of Yugoslavia. These movements also had the support of the Serbian monarchy as they gained the most from it in in 1918 following the Axis' defeat. Following WWII however I believe that national unity was in a large part as previously said attributed to Tito. The economic gains that he enabled though accepting the Marshall Plan aid and a reinvigorated party politic in the early era that tried to distance themselves from Russian control and tried to implement their own unique brand of Socialism mixed with limited private sector scale capitalism helped keep the populace well off relatively and happy. With economic down turns in the late 80s and the rising nationalism promiting parties rising that quickly fell apart, however, not completely, nor without large Western influence, which pitted one petty nationalist group versus another. Tito kept these types of movements in check and the government and popular culture and metropolitan life itself all ppromoted unity. Mixed marriages were happening on higher levels year by year and bands such as Bijelo Dugme hailing from Bosnia, but very mixed on "ethnic" or "religious" lines (choose) whichever you will.
This is merely a summary, we could get a more thorough thread out of this however though input.