Posted September 12, 2017
high rated
Did you know that you can still play Unity games natively on Linux even when they don't have an official Linux build? Neither did I, until I came across this blog entry from January 2016 (which in turn references a Russian How-To). So basically I'm going to closely follow that blog entry (so credit where it's due), plus add a couple of additional instructions/observations for our less tech savvy Linuxers.
If you are curious enough, you might have already noticed that all Unity games have the same structure: one or two binaries, usually named something.x86 and something.x86_64, plus a directory named something_Data. What you might not have ever noticed (I hadn't), is that those binaries have nothing to do with the game itself, but with the particular version of the Unity engine it was created with. In other words, two different games created with the exact same version of the engine will have the exact same 32-bit and 64-bit binaries. This is crucial for our purpose of getting (apparently) non-Linux Unity games to run natively on Linux.
So, what do you need to do to get one non-Linux Unity game running in your Linux box? Just follow these steps:
0) Before anything else, you need to be able to browse the files that make your non-Linux Unity game up. To that effect, you need to uncompress it (in case it comes as a ZIP or a RAR file), or to install it (via Wine or whatever) if it's a binary installer. In the case of GOG installers there's no need to install anything as their contents can be easily extracted with innoextract (most of the time this program doesn't come pre-installed with your Linux distro, but usually it can be found in your distro's package repositories). To extract the contents of a GOG .exe installer you need to make sure that both the .exe and any potential .bin archive that comes with it are in the same directory, and type the following command:
1) Once we have the game's files at our disposal, we first need to find out the exact version of the Unity runtime the game is using. We'll find this bit of information inside the aforementioned something_Data directory. Many files in this directory contain the Unity version inside of them: any of the levelXXX files, any of the sharedassetsXXX.assets files, the mainData, globalgamemanagers, globalgamemanagers.assets, resources.assets files, and probably others will do. I tend to go for level0 or level1, since these files seem to be always there, while others may not. To get the exact version, just type this on a terminal:
If you get a version prior to 4.0.0 (e.g. 3.5.6f4), I'm sorry but you can forget about it. Unity began supporting Linux since Unity v4, so there are no Linux runtimes for earlier versions.
2) The second step is finding a Linux Unity runtime whose version matches the one we just found out.
2a) In practice you can find any one you need, as Unity has them all publicly available. The catch is that you need to download the full release, which weighs more than 1GB and contains thousands of files, when you only need a bunch of them. You can find them in these 3 repositories:
· Full releases (the ones with a X.Y.Zf[-∞] name format)
· Patched releases (the ones with a X.Y.Zp[1-∞] name format)
· Beta releases[*] (the ones with a X.Y.Zb[1-∞] name format)
[*] Only the current beta releases are available for download, so if you need an old beta runtime you're pretty much out of luck. Then again, only 6 out of my 463 Linux Unity games (and more importantly, none of my Windows-only Unity games) use such a runtime, so chances are you're not going to have to bother with that.
2b) An alternative route is to comb your own game library, in case you already have the runtime you need. When looking for a specific runtime you can use this shell command:
2c) Another alternative, which is the one I went with, is to go one by one of your Linux Unity games and identify their runtime versions (by repeating the procedure explained in the point 1). I won't lie to you, it took me quite a long time to go through them all, but now I've got 126 different Linux Unity runtime versions at my disposal. :)
3) Once we've found a suitable candidate, we only need to copy the files we need. They are exactly these ones:
├── something_Data
│ ├── Mono
│ │ ├── x86
│ │ │ ├── libmono.so
│ │ │ └── libMonoPosixHelper.so (since v5.5)
│ │ └── x86_64
│ │ ├── libmono.so
│ │ └── libMonoPosixHelper.so (since v5.5)
│ └── Plugins
│ ├── x86
│ │ └── ScreenSelector.so (since v4.3)
│ └── x86_64
│ └── ScreenSelector.so (since v4.3)
├── something.x86
└── something.x86_64
(Of course, the name of the binaries and of the data directory will vary depending on the game)
In the best case scenario, this is all you need to get the game running natively on Linux. Copy the aforementioned files (renaming them when needed) to where your non-Linux game is located, run either the 32bit or the 64bit binary, and you should be able to play it.
-------------------------------------
Unfortunately, we're not always going to be so lucky. There are many issues that can prevent the game to work just like that (all of them being mentioned in the blog entry I've followed to write this mini-guide), the most common of which is the use of third-party plugins that may or may not be compatible with Linux. For instance, Her Story starts fine with a Linux runtime and everything works flawlessly... until you try to play a video (the videos seem to be using a codec for which there'st no compatible Linux plugin). To be honest, none of the games I've been able to get running does need any 3rd party plugin. It's getting late, so I'll write more about this tomorrow. In the meantime, I hope this is useful to somebody and good look if you decide to try to stay out of Wine™ and try to get Unity games running natively first. :)
PS: I'll be posting in this thread all the games (from GOG or not) that I've been able to get to work, and I encourage anyone who tries the same to share their experiences so we all can have a better (and native) Linux gaming life.
If you are curious enough, you might have already noticed that all Unity games have the same structure: one or two binaries, usually named something.x86 and something.x86_64, plus a directory named something_Data. What you might not have ever noticed (I hadn't), is that those binaries have nothing to do with the game itself, but with the particular version of the Unity engine it was created with. In other words, two different games created with the exact same version of the engine will have the exact same 32-bit and 64-bit binaries. This is crucial for our purpose of getting (apparently) non-Linux Unity games to run natively on Linux.
So, what do you need to do to get one non-Linux Unity game running in your Linux box? Just follow these steps:
0) Before anything else, you need to be able to browse the files that make your non-Linux Unity game up. To that effect, you need to uncompress it (in case it comes as a ZIP or a RAR file), or to install it (via Wine or whatever) if it's a binary installer. In the case of GOG installers there's no need to install anything as their contents can be easily extracted with innoextract (most of the time this program doesn't come pre-installed with your Linux distro, but usually it can be found in your distro's package repositories). To extract the contents of a GOG .exe installer you need to make sure that both the .exe and any potential .bin archive that comes with it are in the same directory, and type the following command:
innoextract --gog setup_whatever_game.exe
This will result in a variable number of directories being extracted: app, game, tmp, commonappdata, and sometimes others. You are only interested in the one that contains the game, i.e. the one with the game binary (something.exe) and the data directory (something_Data). This is usually the app directory, but it can also be the one named game, so take a look around to find the right one. 1) Once we have the game's files at our disposal, we first need to find out the exact version of the Unity runtime the game is using. We'll find this bit of information inside the aforementioned something_Data directory. Many files in this directory contain the Unity version inside of them: any of the levelXXX files, any of the sharedassetsXXX.assets files, the mainData, globalgamemanagers, globalgamemanagers.assets, resources.assets files, and probably others will do. I tend to go for level0 or level1, since these files seem to be always there, while others may not. To get the exact version, just type this on a terminal:
strings level0 | head -1
You should obtain something like 5.5.3f1, 4.6.4.p3, or similar. This is the version of the Unity runtime that game was built for. If you get a version prior to 4.0.0 (e.g. 3.5.6f4), I'm sorry but you can forget about it. Unity began supporting Linux since Unity v4, so there are no Linux runtimes for earlier versions.
2) The second step is finding a Linux Unity runtime whose version matches the one we just found out.
2a) In practice you can find any one you need, as Unity has them all publicly available. The catch is that you need to download the full release, which weighs more than 1GB and contains thousands of files, when you only need a bunch of them. You can find them in these 3 repositories:
· Full releases (the ones with a X.Y.Zf[-∞] name format)
· Patched releases (the ones with a X.Y.Zp[1-∞] name format)
· Beta releases[*] (the ones with a X.Y.Zb[1-∞] name format)
[*] Only the current beta releases are available for download, so if you need an old beta runtime you're pretty much out of luck. Then again, only 6 out of my 463 Linux Unity games (and more importantly, none of my Windows-only Unity games) use such a runtime, so chances are you're not going to have to bother with that.
2b) An alternative route is to comb your own game library, in case you already have the runtime you need. When looking for a specific runtime you can use this shell command:
find . -name level0 -print0 | xargs --null grep --with-filename "4.5.5f1"
Needless to say, substitute "4.5.5f1" in that command for the exact runtime version you're looking for. This command will only scan the directory in which you invoke it and all its sub-directories, so it's a good idea to run it where you've got all your games installed (be it $HOME/games, or whatever). 2c) Another alternative, which is the one I went with, is to go one by one of your Linux Unity games and identify their runtime versions (by repeating the procedure explained in the point 1). I won't lie to you, it took me quite a long time to go through them all, but now I've got 126 different Linux Unity runtime versions at my disposal. :)
3) Once we've found a suitable candidate, we only need to copy the files we need. They are exactly these ones:
├── something_Data
│ ├── Mono
│ │ ├── x86
│ │ │ ├── libmono.so
│ │ │ └── libMonoPosixHelper.so (since v5.5)
│ │ └── x86_64
│ │ ├── libmono.so
│ │ └── libMonoPosixHelper.so (since v5.5)
│ └── Plugins
│ ├── x86
│ │ └── ScreenSelector.so (since v4.3)
│ └── x86_64
│ └── ScreenSelector.so (since v4.3)
├── something.x86
└── something.x86_64
(Of course, the name of the binaries and of the data directory will vary depending on the game)
In the best case scenario, this is all you need to get the game running natively on Linux. Copy the aforementioned files (renaming them when needed) to where your non-Linux game is located, run either the 32bit or the 64bit binary, and you should be able to play it.
-------------------------------------
Unfortunately, we're not always going to be so lucky. There are many issues that can prevent the game to work just like that (all of them being mentioned in the blog entry I've followed to write this mini-guide), the most common of which is the use of third-party plugins that may or may not be compatible with Linux. For instance, Her Story starts fine with a Linux runtime and everything works flawlessly... until you try to play a video (the videos seem to be using a codec for which there'st no compatible Linux plugin). To be honest, none of the games I've been able to get running does need any 3rd party plugin. It's getting late, so I'll write more about this tomorrow. In the meantime, I hope this is useful to somebody and good look if you decide to try to stay out of Wine™ and try to get Unity games running natively first. :)
PS: I'll be posting in this thread all the games (from GOG or not) that I've been able to get to work, and I encourage anyone who tries the same to share their experiences so we all can have a better (and native) Linux gaming life.
Post edited September 13, 2017 by muntdefems