A Unity script that checks if a newer release of your Unity plugin is available on GitHub.
This tool assumes your GitHub releases are tagged with a version number. eg. 1.0.0 or v1.0.0
This script is designed to be included in the distribution of your Unity plugin:
-
Clone the repo into your Unity script directory. Delete the directory
DELETE_ME
as it contains some test stuff. -
Instantiate the checker:
void OnEnable() { GitHub_Update_Checker githubUpdateChecker = new GitHub_Update_Checker() { githubOwner = "your_name", githubRepo = "your_repo_name", currentVersion = File.ReadAllText("Assets/myplugin/VERSION.txt", System.Text.Encoding.UTF8) }; }
-
Render the output:
void OnGUI() { githubUpdateChecker.Render(); }
Tested in editor windows but should work inside custom inspectors.
Auto-check is disabled by default because GitHub rate limits your IP to 60 requests per hour. If multiple Unity scripts use this plugin it will cause them all to break. Use that toggle wisely.
All of these properties are public so you can configure it as much as you want and so you can build your own checker.
* = required
The owner of the repo.
The name of the repo to check.
The current version to use when checking for new versions.
Supports any version you can give to System.Version
and can include a "v". eg. 1.0.0
or v1.0.0
If to check for new versions when the script starts.
If to automatically check for versions every minute (the maximum for rate-limiting).
Allow the user to click a button to manually check for versions. Disabled by default to avoid rate-limiting issues.
Allow the user to download the 1st asset of the release to their Downloads folder (~/Downloads/owner_repo/myfile.asset
). If no binary is set, the sourcecode ZIP is downloaded.
Allow the user to automatically install the asset (if it is a .unitypackage). The user always has the option of opening the containing folder.
The interval (in ms) for auto-checking. See rate-limiting section.
The state of the script - waiting, idle, checking for releases, downloading, error.
A GitHub release if it is newer than our release (or null if none found).
The path to the asset that was downloaded (or null if none downloaded yet).
- detect if any assets have already been downloaded
- disable manual check button if it has been less than 1 minute to avoid rate-limiting