VersionCheck

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
 
m (Text replace - "<javascript>" to "<syntaxhighlight lang="javascript">")
Line 7: Line 7:
  
 
==JavaScript - VersionCheck.js==
 
==JavaScript - VersionCheck.js==
<javascript>var version : int = 1;
+
<syntaxhighlight lang="javascript">var version : int = 1;
  
 
function CheckVersion ()
 
function CheckVersion ()

Revision as of 20:48, 10 January 2012

Author: (Kevin Lindeman)

Description

This script will take the version variable, and check it against a file on your web server. The file just contains the version number. If the version variable is greater than or equal to what the text file shows, then there is no update needed. Otherwise you can have it open up a URL you specify.

Usage

Place this script on a GameObject.

JavaScript - VersionCheck.js

var version : int = 1;
 
function CheckVersion ()
{
    var update_url = "http://mysite.com/myGame/version.txt";
    update_post = WWW(update_url);
    yield update_post; // Wait until the download is done
    if(update_post.error)
    {
        print("There was an error loading the update URL: " + update_post.error);
    }
    else
    {
        var latestVersion : int;
        latestVersion = int.Parse(update_post.data);
        if (latestVersion > version)
        {
            // Put something to tell the user they should update
        }
    }
}
 
function openUpdateWebsite ()
{
    // Replace this url with wherever the user can download the update.
    System.Diagnostics.Process.Start("open","http://mysite.com/myGame/download.html");
}</javascript>
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox