For the last few months, I have been fascinated with Elon Musk’s Tesla Roadster that he launched in to space. I was fascinated so much I even created a website, http://www.whereisroadster.com, which tracks said roadster in it’s travels through space. I watched the video that SpaceX released showing video of the car traveling in Earth orbit for several hours. In that process, I decided that I wanted to make a simulation of what the Roadster would look like, and in the end I decided I wanted to make a screen saver that would show where the Tesla Roadster is in space at any one time, and show it to the user. In the end, I developed a simulation in Unity that looks something like this:
This simulation captured my attention, but I wanted to figure out how to make it in to a screen saver. In the end I ended up releasing this to the Unity Asset Store, but I wanted to give you at least the basics of what is required. The first thing is that your application must be able to run completely on it’s own. This means no inputs, setting up the screen resolution, etc. Secondly, add the “Screensaver Maker” prefab to your starting scene. This prefab will detect when Windows is running your program as a screen saver. Windows supports 3 command line options for screen savers, one for “Settings”, one for “Preview”, and one to run the screen saver itself. So far as I can tell, Unity does not support the “Preview” mode at all, but it can support the other two modes, and that is what my library assists with.
Windows Screensavers are executable programs with a .scr extension that run in the Windows/System32 folder. Because Windows Screensavers are legacy technology, the screen savers actually run with the old file names, so the file names are limited to 8 characters. To run it, you must rename your executable to a .scr extension, and must have no more then 8 characters in the name of the executable. Window rules, not mine. Copy the .scr, data folder, and DLL from the build directory in to the System32 folder, and you can find and execute the screen saver!
The library allows you to adjust many parameters, including a scene for settings, modes to exit the screen saver, etc. I also make use of Scriptable Objects to store the state. In theory you could do a screen saver with a single scene, and just use two included scriptable objects to determine if the screen saver is in execution mode, or settings mode.
I hope you are able to follow these instructions and make some great screen savers! I look forward to seeing what you end up creating in the end!
Ben Pearson is the developer of Colonial Sea Trader, a Unity game that he is producing under the company name Old Ham Media, as well as the website Where is Roadster?. Ben learned Unity development with much assistance with gamedev.tv. You can subscribe to updates at his Google Group, like him on Facebook, check his videos out on YouTube or watch him stream game development on Twitch. He has been a programmer since a young age, although only recently is learning programming with game engines. He has completed the the Complete Unity Developer Course and Pass the Unity Certification courses, and is working through the Complete Blender Developer Course, RPG Core Combat Creator, and Unity Game Physics courses. He is hoping to soon start Unreal Courses soon. Follow him on Twitter @KD7UIY.