Alpha Accesswebsite_badges_steamwishlistwebsite_badges_steamwishlist

Archive

Self-destructing test builds


Well… not exactly self-destructing. This is a simple example of ensuring that a published build won’t run after a certain date.

Why would you want this? It can be useful if you are distributing pre-release alpha builds, press builds, or any version that should only be available for short-term testing. You may have early prototype information and art assets that shouldn’t really be leaked over time. It can also ensure that continued testing means your recipients need the latest version (which still works and isn’t locked out due to being old). It’s not an ultra secure solution, but simple enough to implement for a quick time-based lockout.

You can first define a constant to hold your expiration date (or use another build-configuration variable somewhere). With that in place, it’s simply a matter of making a function that checks if you’ve passed that date, and quits if this is true. If the expiration date is blank, this won’t ever expire (for final public releases).

// define your build's expiration date somewhere, or leave blank to not expire
private string BUILD_EXPIRATION_DATE = "2015-01-01";

// call this function from anywhere (for example in your title scene) to check
// if this build has expired
void CheckBuildExpiration()
{
    if (!string.IsNullOrEmpty(BUILD_EXPIRATION_DATE))
    {
        Debug.Log("This build will expire on: " + BUILD_EXPIRATION_DATE);
        if (DateTime.Today >= DateTime.Parse(BUILD_EXPIRATION_DATE))
        {
            Application.Quit();
        }
    }
}
©2017 Sombr Studio LLC