Step by step guide windows 10 Unity 5.2.3 PATCH 2.0.0
``
**__Please modify and improve this tutorial as you wish.__**
I didnât like the documentation I found in this asset. I prefer a manual! As a client I made this user guide. With P.A.T.C.H. you can create a launcher for updating your game beyond your imagination with the Unity Game Engine or your own software using P.A.T.C.H. external tools.
How to use it
Since the process of updating a software is complex in general, this section will let you understand how to use P.A.T.C.H. in a simple example. I like P.A.T.C.H. because is really smooth but can be difficult the first time. So this guide try to help beginners in a simple scene. We are going to make a simple game that can update itself. Please follow this steps draft guide and improve it as you wish.
Making a game
Letâs start making a simple scene, this will let you understand the workflow of using P.A.T.C.H. But first we need to make some extra work. Since the file is new it is possible that your antivirus will not recognize it. Later this game will be updated and it will be run from another application. We need to configure your antivirus for allowing this to happen. Same antivirus isolate the application or do not let them run other applications. So we can make a special folder where to run the game and later the patcher or updater launcher. Name this folder âPATCH_Exampleâ. We are going to use this folder for all your operations regarding two particular Unity project. In it it will be our game project and the launcher project.
example:
**C:\Unity\PATCH_Example\**
Then go to your antivirus security section and look for auto sandbox if there is one. Add the folder **PATCH_Example**
to the ignore list. So it does not isolate the applications that run into it. You can add also Unity.exe in the exclusion ad if there is an option rule, change it from allowed application to installer Updater.
Now you are ready and you can start making the game.
-
Open Unity as administrator. This is a good way and if you do not do it you can get problems along the road.
-
Go to your Unity icon, right click
-
In the long list, choose run as administrator
-
Enter the password if needed
-
In this Unity we are going to make a Game in a simple scene.
-
Choose â+NEWâ in the top left icon
-
Enter project name âtestâ. This will be the name of the game.
-
Choose the location path in your PC. C:\Unity\PATCH_Example\
and add a folder name: âGameâ. and select it. The Location full path must be: C:\Unity\PATCH_Example\Game
-
Make it 3D and when you are ready choose âCreate projectâ
-
Now we are going to save the game.
-
Go to âFileâ , âSave Sceneâ and
-
call it âtest 0â or the name you want.
-
Make a build of the game
-
Go to âFileâ â âBuild Settingsâ
-
Add the scene by pressing âAdd currentâ
-
Select âPC Mac Linuxâ and click âBuildâ
-
In the window make a folder call it âGameBuildâ
-
Open the folder âGameBuildâ
-
And in it add the Game name that in this case will be âtestâ. This name is important
-
Click âSaveâ. And Unity will start building the game.
-
The build will be created and a folder window will appear containing the game âtest.exeâ and a folder âtest_Dataâ. This will the game that we will update later. Do not close this window.
-
Minimize the window containing âtestâgame.
-
In Unity, close the build settings window and
-
Do not close Unity, minimize it too.
Making the launcher
You can add P.A.T.C.H. in your game project with no problems and use it (or build it) from that location. Definitively, you donât need to create new project for P.A.T.C.H. because it is integrated as simple Unity plugin, but for this example we are going to make the launcher in a different Unity editor. We will have two different Unity projects open. This way itâs simpler to manage the game from outside the firs-time. And if there is a problem updating the asset it will not interfere with your game production.
Since the launcher will call and run the game âtest.exeâ we need to make the same configuration first to our PC. We need to tell the antivirus to not isolate the application or not to execute it in a virtual environment. Since we have done this before while setting up the folder âPATCH_Example
â, we will use this folder. We need to make a new Unity application in the folder âPATCH_Example
â C:\Unity\**PATCH_Example**\
it will not run virtually. Remember to open Unity in administrator mode following the step by step.
-
Open a second Unity as Administrator mode. This is possible since Unity 5.
-
After entering the password, choose â+NEWâ
-
in Project name: âNew PATCH Projectâ
-
Location Path: In the path â**C:\Unity\PATCH_Example\**
" add a new folder next to âGameâ folder, call it â**Launcher Example**
â. Select it. The final full Location path must be: â**C:\Unity\PATCH_Example\Launcher Example**
â
-
Make it 3D and when you are ready choose âCreate projectâ
-
In top bar go to âWindowâ â âAsset storeâ, if is not open.
-
Choose P.A.C.H. download it and import
-
You can find same alerts (3 warnings in console). Reset the application
-
In the Unity tool icon bar on the right click âlayoutâ and choose âDefaultâ to reset the the application interface layout. This will close the asset store.
-
Now save the Project. Not the Scene.
-
Close Unity and open it one more time as administrator mode. Enter the password.
-
Choose âNew PATCH Projectâ this will reload the application. Notice the as admin mode the Unity projects list is different from opening in a direct way.
-
Now we are going to make the first version note containing the version number.
-
When Unity is open, choose in the top bar âWindowâ â âP.A.T.C.Hâ â âPatch builderâ.
A P.A.T.C.H. tab window will appears. This also makes a special PATCH folder. With the first run (when you click on Window â P.A.T.C.H. â Patch Builder), it will create a folder in your projectâs root folder called âPATCHâ; it contains all directories and files that P.A.T.C.H. needs.
Do not press âNew versionâ. If you press âNew versionâ button, P.A.T.C.H. will give you:
âSomething goes wrong during new version building process init!
â
This is because there are no info in the âcurrentâ folder. You need to fill your âcurrentâ directory with your game build. In my case if you have done other builds you can get an error:
"Version checking error! Please check your version file!"
In any way we need to configure Patch builder first. We are going to add the build version of our game to a particular folder. Now the folder âcurrentâ is empty and we need to add to it the game.
-
- We need to go to âcurrentâ folder that will be in the path:
**C:\Unity\PATCH_Example\Launcher Example\New PATCH Project\PATCH\current**
We can go there by selecting in the editor the tab âProjectâ, âAssetsâ, right click and select âShow in explorerâ. this will open a window located in âNew PATCH Project
â. In it there will be **PATCH
**folder.
-
Go into âPATCH
â folder and there will be 3 folders: builds, current and patch
-
Go into âcurrent
â folder. Here we need to put the build of the game.
-
Do you remember that we minimized a window containing our game? Now is time to open it and put it side by side the âcurrentâ folder.
-
Drag and drop copying the content of âGameBuild
â into âcurrent
â. You need to copy or move the âtest.exeâ file plus the folder âtest_Dataâ into the folder âcurrent
â. You can copy or move it.
-
Now return to Unity âNew PATCH Projectâ.
-
In the editor there is a tab name âP.A.T.C.H.â that was previously opened. You can doc it in same place in the inspector as you wish.
-
Close the P.A.T.C.H. builder tab and reopen it.
-
Now you can press âNew versionâ for making the game file version. If is hidden or if you have hit âNew versionâ previously it will be hidden so restart Unity or reset the interface by clicking âDefaultâ in the top right and then re-open Patch builder: Window > P.A.T.C.H. > Patch Builder. And click âNew Versionâ only one time. If you had follow all the steps accurately, you must get blue lines and a text telling Congratulations: âA new build version has been processed!â and âBuild completed!â
-
Now save the project by going into âFileâ â âSave Projectâ. Do not confuse, itâ is not save scene, it is save project. This is important if not there is a possibility that Patch builder is reset.
-
Return to the explorer window where itâs opened âcurrentâ folder.
-
As you see the folder âcurrentâ is empty now the game is in the folder âbuildâ with extra files
-
Go up to the PATCH folder and then go into âbuildâ folder. There is a version 0.0.0.0 with extra files. Ignore this extra files for now.
-
Go into the folder â0.0.0.0â. Here is your not compress game and a game âversionâ file.
-
In this folder we need to include the launcher and we are going to do that later. The launcher will look into the game âversionâ file before calling the âtest.exeâ app game. Before that we need to configure and make the launcher.
-
Do not close the window. Minimize it
-
Now we go back to Unity âNew PATCH Projectâ
-
Open the example scene âLauncherâ that is in:
**Assets\MHLab\PATCH\Source\Launcher\Scenes\LauncherStyle1**
- In the Hierarchy click the game object âLauncherâ so we can look it in the inspector.
- In the Inspector there is a component name âLauncher" c# script
- In version File Download field you must put the URL of your server where will be the next version file. we havenât done the file yet but you need to imagine and choose a URL path where will contain the version file to read:
**http://yourserver.com/...path.../yourgame/patches/versions.txt**
- In Patches Directory URL you need to add the path URL of your server that will contain the files to update your game.
http://yourserver.com/...path.../yourgame/patches/
- Build Directory Is not used in this example. Leave it how it is.
- Go to App To Launch and add âtest.exeâ that is the name of the game to be launched after the update. leave the rest as default.
- The launcher will not work in editor. Do not press play and launch it. If you did so youâve probably got a message:
NullReferenceException: Object reference not set to an instance of an object
Localizatron.loadLanguageTable (System.String fileName) (at Assets/MHLab/PATCH/Localizatron/Core/Localizatron.cs:56)
Localizatron.SetLanguage (System.String language) (at Assets/MHLab/PATCH/Localizatron/Core/Localizatron.cs:26)
Localizatron.Init () (at Assets/MHLab/PATCH/Localizatron/Core/Localizatron.cs:83)
Localizatron.Awake () (at Assets/MHLab/PATCH/Localizatron/Core/Localizatron.cs:87)
UnityEngine.GameObject:AddComponent()
Singleton`1:get_Instance() (at Assets/MHLab/PATCH/Localizatron/Core/Singleton.cs:31)
Launcher:Start() (at Assets/MHLab/PATCH/Source/Launcher/Scripts/Launcher.cs:45)
Because we need to create a localiz**ation file with Localizatron. We must resolve this first.
- Go to Window â Localizatron . (Cool name!)
- Add in the empty field en_EN and press âAdd new location fileâ. This will add a language English. Do not add more for this example.
- Just close the Localizatron tab
- Save the scene âSave Scene asâ with a new name, for example âMy Launcherâ
- And save the Project.
- Do not close Unity. Do not Minimize it.
Adding the launcher to the game
Now that we have made the configuration to My Launcher, we are ready to cook it (compile it making a build). We are going to build and run the launcher in the same folder where is the game.
-
In unity My launcher - New PATCH Project, we must build My Launcher scene in the correct directory next to the game where is the game âversionâ file.
-
Make a build, by clicking in âFileâ â âBuild Settingsâ
-
Select âAdd currentâ to add the scene in the build
-
Select âPC Mac Linux StandAloneâ
-
And press âBuild and Runâ so we can make a first test. A window will appear.
-
Select the folder âPATCHâ â âbuildsâ â â0.0.0.0â.
-
In the folder â0.0.0.0â choose a name âlauncherâ.
-
Click âSaveâ. It will start making the build and then it will run.
-
Mark the check box Windows to [true] and hit âPlay!â. So the Launcher will start.
-
The Launcher must run and will try to check for updates. Just move the window to refresh the launcher status if the bar are hidden. The launcher can´t check the version because we didnât make the folders in the server and launcher canât find the files. But will show in the GUI a message âFound version 0.0.0.0â. So we need to upload the updates to the server.
-
You can try to run the Launcher as administrator mode.
-
Close the Launcher.
Uploading the game to the server
PATCH does not include indications for making an installer. Or a tool to upload to the server via FTPS. Can be in the future with further updates. At the moment the installer feature is ready and will add it in next release.
What we can do is to Upload the folder â0.0.0.0
â to the server with a different name. All you need for sending it to a friend or a player is: copy the folder â**0.0.0.0**
â, rename it and zip it. The first version of your game will be there in that zip. You can upload to the server but remember that in this example, it will not work until we have the first patch. Do not change the name of the original folder â**0.0.0.0**
â inside **PATCH\builds**
. Make a copy of it instead.
- I suggest first to copy the folder â0.0.0.0â to a new location in your PC. For example into:
C:\Unity\PATCH_Example\File To Upload\0.0.0.0
Fitting into PATCH_Example
you do not need to make configurations to your firewall or antivirus
- Then change it name from â0.0.0.0â to â
MyGameName
â
- Zip it or make an installer using same tool as for example winrar, wix, etc.
- Upload the file to the server and make a download link to it.
We need to make and upload the path before downloading and playing the game in this example. There is always a better way to do all this but this is the way it works for me. So lets make the patch!
Making a modification of the game
Now return back to the Unity where is open the game. We minimize it in the background. If you close it, open a new Unity editor in administrator mode. In it make the modifications of the game as you wish. I will go faster because now you know where to click.
-
Go to Unity âtestâ game for making same modifications and open the scene âtest 0â if was close.
-
Create for example a 3D object cube.
-
Now âSave Scene asâ if you want âtest1â or âScene1â. this is not necessary but is nice to be organize
-
Save the project
-
Build the game by clicking in Build Settings
-
Remove the old scene âtest 0â and add the new scene âtest1â.
-
To remove the old scene âtest 0â select it and press delete.
-
Press âAdd currentâ to include the scene âtest1â.
-
Click âBuildâ
-
A window will pop up and choose the same âGameBuild
â folder. The build will be made in the same position. The name must be the same âtestâ. or if you wish you can build it directly in âcurrentâ. I will save it here in Game in this example.
-
Press âSaveâ button
-
After the build is done, a new explorer window will open. Select the test.exe file and the âtest_Dataâ folder.
-
With the two selected, right click and choose copy. We are coping the files to the âcurrentâ folder
-
Open the other explorer window that was minimized. It will probably be in the folder â0.0.0.0â and go to **PATCH/current**
folder. In â**current**
â folder that was empty now we are going to pass the new version of the game.We are going to copy or move it as you wish.
-
Past into this âcurrentâ folder the game. Or make the drag and drop. You are ready for making the patch
Making the patch
If you started reading from here for making a patch, please follow or read the steps before: âMaking a modification of the gameâ.
Using the patches builder you can quickly and easily create a patch between two build versions. If you want the external version you will find it in
Assets/MHLab/PATCH/Source/PatchBuilder/PatchBuilderWinForms/PatchBuilderWinForms.zip.
In case you want to use the external one, extract it where you want it . I recommend out of Unity project!
In this case we are working in Unity with a Unity game so we are going to make a patch there.
- Open or return to Unity âLauncherâ where there is the NewPATCH project. Remember to open Unity in administrator mode if you have close it previously.
- Close the Build settings tab window if is still open.
- The âPATCHâ tab patch builder tool probably is open if not go to âWindowsâ â âPATCHâ â âPatch Builderâ. Now you are ready to make the patch.
- You can choose the New version number but we will live it as it is for now. Probably will be 1. It updates automatically each time we press the New version button
- Click in âNew versionâ.
- In my case i found this error but no customers reported the same error yet. Is probably my PC or my particular configuration. If you find this error:
NullReferenceException: Object reference not set to an instance of an object
PatchBuilderWindow.OnPatchBuildingContext () (at Assets/MHLab/PATCH/Source/PatchBuilder/Editor/PatchBuilderWindow.cs:298)
PatchBuilderWindow.OnGUI () (at Assets/MHLab/PATCH/Source/PatchBuilder/Editor/PatchBuilderWindow.cs:224)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[ ] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222
Then you need to⌠Save the project and the scene. Restart Unity or reset the interface to default and reopen âPatch builderâ. Remember if you restart the Unity application, open it in admin mode. Now retry one more time pressing âNew versionâ. All must work fine.
- If all works fine a blue line rendered with a message in it âBuild completed!â. You have created a build but not the patch yet. The build will be in the folder âPATCH/buildâ name â0.0.0.1â. Now we need to create the patch.
- You can see now that there are more options in the patch builder. Just hit âBuild patchâ. P.A.T.C.H. will create a new different patch between those builds, it will inform you on what it is doing and, finally, it will create or update the versions list. A blue line will show you the progress and a text âPatch completedâ will appear.
- If we go to the PATCH folder containing the 3 folders âbuildsâ, âcurrentâ and âpatchesâ now we understand for what they are for.
builds: this directory will contain our processed builds
current: in this directory we will place our current build. We can directly build our project in this directory from Unity3D without problems.
patches: in this directory we will find computed patch archives and versions list, with archives hash. this are the files that we will upload to the server.
logs: if some error occurs, patches builder will create a log directory with a log file to store information about errors.
- Save the Project. This is important.
Uploading to the server
The folder âpatchesâ contain all what we need to upload to the server. Open the folder âpatchesâ and in it we will find 3 files. In particular the file âversion.txtâ contains instructions: 0.0.0.0>0.0.0.1>yGcR9m0ox6bYbZIIdmlv4LFzvX0>ZIP
that tells the launcher what to update, the hash and the compression mode of the patch itself. We can now upload all this files or the folder âpatchesâ to our server in the same location as we add into the inspector URL.
**http://yourserver.com/...path.../yourgame/patches/**
- Open the ftp software and we upload to:
http://yourserver.com/...path.../yourgame/patches/
the content of the folder âpatches
â
Testing the Launcher
Downloading and playing the game
Now you can download the zip game, extract it into a folder you wish and execute it by running first the launcher in admin mode. The application must run as before. Remember to include instructions on how to run it next to the download button in your website.
- Now we open the launcher that is in:
C:\Unity\PATCH_Example\File To Upload\MyGameName
buy right click in âlauncher.exe
â and choosing open as administrator mode.
If you are having problems at this point the only thing I can imagine is that the firewall, the antivirus is not letting you to run it correctly. So make the application trust worthy. This is sometimes needed because same antivirus does not allow an application to call and run other application.
If all has been done correctly and if I was good enough to make this step by step guide, now when you start the launcher, it will check the server patch version number, it will compare it to the game version number and make the download.
Adding Launcher to your game
You can modify the step by step guide making a new Launcher for your game. I recommend to name the launcher as the name of your game. And the game as the name of the scene or level. In this way the user is not confused. Better if you put the final game in a child folder so the user can find first the launcher with the game name.exe.
Examples ideas
Other modifications can be done. As for example make silent updates. Or you can modify the launcher to work when the application is closing. In this way the player can play without waiting. You can include a turn my PC off when done option. Other example is to download the update at start and start the game. When the download is finished it can make the installation of it at the next start.