Skip to content

Getting Started

Emanuele Manzione edited this page Mar 10, 2022 · 13 revisions

Forewords

The whole documentation assumes you are working on Windows, so commands and everything else refer to its environment. If you work on a different OS, don't worry: the process is the same, very minor changes in commandline commands are needed.

Also, it assumes you own the PATCH - Updating System package from Unity's Asset Store.

Installation

Unity

Just import the package in your project into Unity Editor. After importing, your project should contain atleast these folders:

After import

To check if it is correctly installed, go on Window menu and make sure you can find the PATCH menu item.

Window

Click on Admin Tool to start an in-editor tutorial! Follow it together with this Wiki!

WPF

If you don't want to use Unity to build your Launcher, you can use the WPF version. You can find it inside the package you imported from the Asset Store at this location: Assets\MHLab\Patch\Launcher\MHLab.Patch.Launcher.Wpf.7z (for Basic) and Assets\MHLab\Patch\MHLab.Patch.7z (for Pro). Extract it in a folder outside of your Unity project and you are ready to open it with your .NET IDE (Visual Studio or Rider offer a good WPF Editor).

If you are on Basic version, once you opened the project, your IDE will complain about missing projects. That's normal: it looks for some projects that only exist if you own the Pro version. No worries, you can replace them with the two DLLs contained in the archive: MHLab.Patch.Core.Client.dll and MHLab.Patch.Core.dll. Add them as dependencies and the IDE won't complain anymore!

How does this updater work?

Before we dive into the software itself, here is a little bit of theory. I know, I know: it is boring. But it is needed. In this way you completely understand what we are going to do here.

When you develop a game or an application, you also want the ability to deploy updates and fixes for it. There are multiple ways you can deliver updates for your software, but the most intuitive one in my opinion is the classic Launcher. The Launcher is a software that is not embedded into your own application/game: it is standalone and it runs before your game. It repairs corrupted/damaged files, it checks for updates, it applies updates, then it starts your game if everything is ready.

You may also need to deploy updates for the Launcher itself: so it also needs to self-update. In this package I propose two ways of self-updating: one for Unity and one for WPF.

Scenes

The package comes with an example of a classic updating architecture. You can find sample scenes in MHLab/Patch/Launcher/Scenes:

  • Launcher. It is the scene that contains your Launcher logic and UI. It updates your game. In the hierarchy find a LauncherData game object: it contains settings for your Launcher script.
  • PreGame. It is the scene that contains your Launcher self-updating logic and UI. It updates your Launcher. You need to set it as first scene in your game. In the hierarchy find a LauncherData game object: it contains settings for your LauncherUpdater script.
  • SampleGame. It represents your game, it is just a placeholder.

Setting up

To distribute updates you will need a web server or any other service that can serve files over HTTP. The Launcher's downloader can access files through direct URLs, like: http://yourIP/yourFolder/yourFile.exe, so make sure that your files host serves them correctly! For testing purposes you can also use a local web server like WAMP.

Decide what will be your remote workspace on your web server: I'll pick http://localhost/patch/ folder. So fill LauncherData component with your settings in both Launcher and PreGame scenes.

Launcher Data

In PreGame scene you will also find the LauncherUpdater game object: set the Scene To Load property inside its LauncherUpdater component. It is the index of your game scene in your build settings.

WPF

If you are on WPF, the configuration is a bit different. Of course you have no game objects. Open the MainWindow.xaml.cs and reach the CreateSettings method: modify its content to match your needs!

Build settings

When you build your Launcher, you have to include atleast the Launcher scene at index 0.

Launcher build settings

When you build your Game, you have to include the PreGame scene at index 0. SampleGame represents your main game scene.

Game build settings