Skip to content
This repository has been archived by the owner on Jul 1, 2020. It is now read-only.

Integrating SimplePatchTool

Süleyman Yasir KULA edited this page May 15, 2020 · 2 revisions

Prerequisites

  • take a look at the Glossary to familiarize yourself with the terms that are used throughout the wiki
  • SimplePatchTool needs to know where to download VersionInfo.info from. See Generating versionInfoURL to generate this url
  • if this is a self patching app (i.e. this app will be able to patch itself), then you'll need to create a self patcher. You'll find instructions on where to put the self patcher later on
  • while creating patches, it is possible to sign the important patch files with an RSA key pair. This optional feature offers increased protection against man-in-the-middle attacks. If you are interested, then you need to generate an RSA key pair and embed the public key's contents into your application (e.g. in a string constant)

There are two ways to integrate SimplePatchTool:

A. Using Scripting API

Click here to show/hide

With this method, you use C# to control the patching process. Simply follow this guide to learn how: https://github.com/yasirkula/SimplePatchTool/wiki/Integrating-SimplePatchTool

To avoid any Mono related issues while applying patches in Unity, you should configure the SimplePatchTool instance as follows:

SimplePatchTool patcher = new SimplePatchTool( ... )
// default IDownloadHandler implementation doesn't support https in Unity
.UseCustomDownloadHandler( () => new CookieAwareWebClient() )
// default implementation (DriveInfo.AvailableFreeSpace) throws NotImplementedException in Unity 5.6.2,
// so skip this stage until a Unity-compatible solution is found
.UseCustomFreeSpaceCalculator( ( drive ) => long.MaxValue );

Alternatively, you can call the SPTUtils.CreatePatcher( string rootPath, string versionInfoURL ) function which returns a Unity-compatible SimplePatchTool instance.

To check for updates/apply a patch and wait for the operation to finish in a coroutine, you can use the following SimplePatchTool extension functions: CheckForUpdatesCoroutine and RunCoroutine.

B. Using PatcherWrapper Component

Click here to show/hide

For simple patcher integrations, you can use the Patcher Wrapper component to quickly create a customizable patcher with a number of properties and events. Most of these customization options have tooltips or explanatory texts to help you understand what is what. To fill the Version Info URL field, see Generating versionInfoURL.

PatcherWrapper has the following properties and functions:

string RootPath { get; }: calculated root path of the application

string ExecutablePath { get; }: calculated path of the application's executable

SimplePatchTool Patcher { get; }: the SimplePatchTool instance this component is using to check for updates/apply patches. You should not call SetListener on this instance since it would prevent PatcherWrapper's events from getting invoked

void CheckForUpdates(): starts checking for updates

void ApplyPatch(): starts updating the application

void RunSelfPatcherExecutable(): if this is a self patching app, runs the self patcher to finalize the update. This should only be called if the patcher reports a successful patch (i.e. the Patch Successful event is an ideal place to call this function)

void LaunchApp(): launches the app (i.e. starts the app located at ExecutablePath). Can be useful for launchers launching the main app

void Cancel(): cancels the currently running operation