>>3407356>>3407417>>3407686>>3407784Pain wanted to redistribute bijuu nukes. His expectation was any time war broke out it would escalate into the nukes being used, which would cause so much pain and suffering that people would stop fighting. At least until a few generations later when they forget how bad war is and it happens again. It was essentially the existing ninja system of cyclical war and peace but with the wars a lot shorter and more devastating and the periods of peace hopefully longer. Uniting people against him wasn't specifically part of this, but in trying to achieve it Konoha stood firmly with Naruto and against him. Had he succeeded, people would not be united against him. In fact his existence is no longer specifically necessary if he succeeds.
Obito is the one who united the entire world against him. He wanted to put everyone including himself in a shared mass illusion which eliminates pain and suffering, leaving only peace. Since people would live peacefully in the same illusion they could theoretically be considered united, though not specifically against anyone. Uniting people against him wasn't part of the plan, but arguably he united them intentionally at the summit. I will have to think more about this. It's slightly different than Pain who shows up and offers to individual villagers that if they give him Naruto he will leave. Obito makes a similar demand to hand over the jinchuuriki but he treats the Kage as a unified front, immediately making it "me vs. all of you".
Madara wanted to put everyone into individual illusions, which also eliminates pain and suffering, but doesn't really unite them since they're all in different dreams. Uniting people against him isn't part of this plan either, and the world was already united by the time he arrived.
Sasuke wanted to unite people against him so they would stop fighting each other and instead fight him. Uniting against him is specifically the end here, not a means to an end.