Recovering Unity Without Restarting
Press Ctrl+Alt+F1 to switch to a virtual console. Log in with your username and password. As you enter your password, you won't see anything change, but that's OK.
You'll get a shell prompt (which ends like $ _
). Run this command:
compiz --display :0 --replace
Then press Ctrl+Alt+F7 to go back to the GUI. If that doesn't work, switch back to the first virtual console (Ctrl+Alt+F1) and run:
unity --reset
Then switch back to the GUI (Ctrl+Alt+F7).
One of those will probably work. You don't have to log out in the virtual console, but if you want to (for example, so that people can't switch to it when you're logged out or have a locked screen), you can do that by running the command exit
in it.
Restarting Safely, If You Have To
If you find you do have to restart your computer, you should avoid hard resets. Instead, you can switch to a virtual console Ctrl+Alt+F1, then reboot with Ctrl+Alt+Delete.
If that doesn't work, you can do something that is nearly as powerful as a hard reboot, but which decreases the risk of data loss and other possible negative outcomes of hard rebooting. Hold down Alt and SysRq and, in order, press R E I S U B. (Hold down Alt and SysRq the whole time, but release each letter key before pressing the next one.) See this page for a simple explanation of what that does, and this Wikipedia article for more detailed information.
Reporting the Bug
Since you've found a bug, I recommend reporting it--this should help get it fixed sooner, plus there might be workarounds you can use to fix it yourself on your computer, which you'd find out by searching for the bug (or by reporting it and finding that your bug is a duplicate of an existing one).
Ubuntu's community documentation explains how to report bugs properly.