Fri, Apr 15, 2016

Auto Updating Unity3D Assets

I've been releasing Unity3D assets outside of the official Asset Store for a while now and although this brings quite a few benefits, one of the big downsides is missing out on the auto update functionality Unity's store provides. Expecting users to manually keep track of new releases, for multiple assets, across multiple locations is unrealistic. I want to improve this.

The Asset Updater

My requirements for the Asset Updater were simple; enable users to check for and download asset updates, display version/release notes and work with multiple assets in a single project. Ideally it should also be as painless as possible for developers to maintain. The Asset Updater works by using a small XML file to compare the version number of the local copy with latest version stored in some remote location.

When the user opens the Asset Updater window (Window/kode80/Check for Asset Updates) it quickly searches the project for all AssetVersion.xml files, does remote version checks and displays a list of all assets along with release notes and package downloads if new versions are available.

Level template editing in Tiled editor

AssetVersion.xml Files

The AssetVersion.xml files themselves are very compact, requiring just 6 elements to describe the asset version. Name and Author are self explanatory. Version is the semantic version of the asset. Notes is the text displayed when the user presses the "Release Notes" button in the Asset Updater. Finally, package-uri and version-uri point to the download location of the latest unitypackage and remote AssetVersion.xml file respectively.

<asset>
    <name>kode80 Clouds</name>
    <author>kode80</author>
    <version>1.0.0</version>
    <notes>First release of kode80 Clouds.</notes>
    <package-uri>https://kode80.com/downloads/assets/kode80Clouds.unitypackage</package-uri>
    <version-uri>https://raw.github.com/kode80/kode80CloudsUnity3D/master/Assets/kode80/Clouds/AssetVersion.xml</version-uri>
</asset>

Since the remote AssetVersion.xml file can be stored anywhere that's publicly accessible, it's possible to integrate the update process into your source control workflow. All my assets are hosted on GitHub, which allows direct linking to raw files in the repository. This means that as soon as I commit the updated AssetVersion.xml file with a new release, that release is immediately accessible from the in-editor Asset Updater. Needless to say this is a win for both users and developers.

Enabling Updating in your Asset

If you are a developer of open source assets, distribute your assets outside of the Asset Store or wish to keep your team in sync with internal assets, you can easily enable asset updating by simply adding an AssetVersion.xml somewhere in your asset's folder and including kode80 UnityTools.

UnityTools is of course updatable itself, so keep an eye out for future updates and if you run into any issues or have suggestions for improvement, please get in touch.