Skip to content
 
 

Latest commit

 

History

26 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Patch Tool for Unity

Available on Asset Store: https://www.assetstore.unity3d.com/en/#!/content/124296

Forum Thread: https://forum.unity.com/threads/simplepatchtool-open-source-patching-solution-for-standalone-platforms.542465/

This plugin is a Unity port of the SimplePatchTool library, a general-purpose patcher library for standalone applications. Before using this plugin, you are recommended to first see SimplePatchTool's documentation: https://github.com/yasirkula/SimplePatchTool

LICENSE

SimplePatchTool is licensed under the MIT License; however, it uses external libraries that are governed by the licenses indicated below:

HOW TO

  • import SimplePatchTool.unitypackage to your project
  • in Edit-Project Settings-Player, change Api Compatibility Level to .NET 2.0 or higher (i.e. don't use .NET 2.0 Subset)
  • (optional) in Edit-Project Settings-Player, enable Run In Background so that SimplePatchTool can continue running while the application is minimized/not focused
  • you can now use Window-Simple Patch Tool to create/update patches, sign/verify xml files and generate RSA key pair:

editor_window

Updating Dll's

This plugin uses SimplePatchTool's SimplePatchToolCore and SimplePatchToolSecurity modules without any modifications; so, if you want, you can make any changes to these modules, rebuild them and replace the dll files at Plugins/SimplePatchTool/DLL with their updated versions.

Unity-specific Changes

To avoid any Mono related issues while applying patches in Unity, you should make the following changes to SimplePatchTool in your codes:

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.

About Self Patcher Executable

SimplePatchTool comes bundled with a self patcher executable on Windows platform. To add self patching support to macOS and/or Linux platforms, or to use a custom self patcher executable in your projects, you need to follow these steps:

  • build the self patcher executable
  • move the self patcher executable and any of its dependencies to the following directory:
    • Windows: Plugins/SimplePatchTool/Editor/Windows
    • macOS: Plugins/SimplePatchTool/Editor/OSX
    • Linux: Plugins/SimplePatchTool/Editor/Linux
      • these files will automatically be copied to a subdirectory called SPPatcher after building the project to standalone (if you want, you can set PatcherPostProcessBuild.ENABLED to false to disable this feature)
  • update the name of the self patcher executable in SPTUtils.SelfPatcherExecutablePath property
  • you can now run the self patcher like this: patcher.ApplySelfPatch( SPTUtils.SelfPatcherExecutablePath );
  • or like this, if you want to automatically restart the game/launcher after self patching is completed: patcher.ApplySelfPatch( SPTUtils.SelfPatcherExecutablePath, PatchUtils.GetCurrentExecutablePath() );

EXAMPLES

Some of the example scenes use the PatcherUI prefab to show SimplePatchTool's progress to the user; feel free to use it in your own projects, as well:

patcher_ui

If you sign your VersionInfo and/or PatchInfo files with private RSA key(s), you can paste their corresponding public RSA key(s) to the Version Info RSA and/or Patch Info RSA variables in the demo scenes.

If you plan to add self patching support to your app or test a demo scene that makes use of self patching, make sure that your target platform's self patcher executable is set up.

patcher_ui

This scene lets you tweak some variables at runtime to quickly test some patches with different configurations. It can run on the Editor.

patcher_ui

Video tutorial: https://www.youtube.com/watch?v=Gjl6my7rVSI

This scene allows you to quickly create and test a self patching app. It can't run on the Editor.

You can test this scene as following:

patcher_ui

Video tutorial: https://www.youtube.com/watch?v=P7iUQ-n3EQA

This scene allows you to quickly create and test a launcher that can self patch itself in addition to patching and launching a main app. Launcher first checks if it is up-to-date (if not, self patches itself) and then checks if the main app is up-to-date (if not, patches it). If you don't provide a VersionInfo url for one of these patches, that patch will be skipped. This scene can't run on the Editor.

You can test this scene as following (you are recommended to test the SelfPatchingAppDemo scene first):

  • read these instructions to understand the recommended project structure for launchers
  • generate versionInfoURL's for the launcher and the main app and paste them to the Launcher Version Info URL and Main App Version Info URL variables of LauncherUI in the Inspector
  • decide a Main App Subdirectory (let's say MainAppBuild) and Main App Executable (let's say MainApp.exe)
  • build this scene to an empty directory (let's say LauncherBuild)
  • build another scene/project to another empty directory (MainAppBuild) and name the executable MainApp.exe (this directory will be our main app)
  • create a patch for the launcher using LauncherBuild directory as Root path while adding MainAppBuild/ to the Ignored paths
  • complete the After Creating a New Patch part, as well
  • create another patch using MainAppBuild as Root path (which will be the main app's patch) and complete After Creating a New Patch part for it, as well (you are recommended to keep the launcher's and the main app's patch files in separate directories on the server for clarity)
  • now create a copy of the LauncherBuild directory and copy&paste the MainAppBuild directory into it to test the launcher
  • try deleting a redundant file of the launcher (e.g. something from the Mono/etc subdirectory). When you launch the launcher, it will automatically detect this change and prompt you to update/repair itself
  • try deleting a file from MainAppBuild and hit the Repair Game button in the launcher to repair the main app
  • try creating newer versions of the launcher and/or the main app (see SelfPatchingAppDemo to learn the process) and verify that the old launcher correctly patches itself and/or the main app to the newest version(s)

About

Unity port of SimplePatchTool library to add patching support to standalone Unity applications

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages